qlik-sense-power-automate-uptime-notification

Qlik Sense site uptime via Power Automate

Nearly a year ago, I blogged about using Power Automate from Qlik Sense to send notifications to Teams channel and send emails. This time I would like to explore a different area, how to use Power Automate to monitor your Qlik Sense Proxy Service (QPS) availability and send notifications when it’s not accessible.

What is Qlik Sense Proxy Service?

The Qlik Sense Proxy Service (QPS) is responsible for session handling, user authentication and load balancing. When a user accesses the Qlik Sense site using a web browser, this is the first service that deals with the user requests. The Qlik Sense service architecture below shows how QPS works in a typical single node deployment.

Qlik Sense architecture
Qlik Sense architecture (Source: Qlik)

Why?

A common question that I come across from the IT/Qlik administrators is, “Is there any way to be notified when the Qlik site is not accessible?”. As an administrator, you do not want to be notified by your business users that Qlik Sense site is down, most probably, you would like to be the first one to notice it and deal with it before the business users face any issues. As shown in the architecture above, QPS is responsible for dealing with the user requests. QPS is listening to port 443 (or 80 if http is enabled) and deals with user authentication and sessions. So, when this service is down, users will not be able to get a session, delete a session or log in, resulting in Qlik Sense service outage. When a site is not accessible, this is the first service to check to make sure that it is working. This is why, performing health check on this service periodically allows a site administrator to be more proactive when something go wrong.

How?

There are number of ways we can systematically check the site’s availability and uptime. You can use online services such as http://www.uptrends.com to check and even automate this process, but that requires a paid subscription to that service. For me, I wanted to use something really simple and allow administrators to utilise the Power Automate platform that they might already be using for other business processes.

To make this solution work, I will use the QPS API user endpoint that requires no user authentication.

https://yourrqlikserver.com/virtualproxy/qps/user

I will simply make a HTTP GET requests to that endpoint and observer the HTTP status code. When the service is up, I should get a response with HTTP status code 200 and the following message (provided not made the call with a logged in user) –

{
  "session":"inactive"
}

My QPS health check notification flow would look like this –

  1. Use Power Automate HTTP action to make a GET request to the QPS user endpoint
  2. Observe the response HTTP status code
  3. If we received anything other than HTTP status code 200, then send an email alert using Power Automate “Send Mail” action
Power Automate notification flow design
Power Automate notification flow design

Let it flow…

Now that I have covered the initial design of the flow, let me take you through the steps to build it.

Note: I am using “Scheduled cloud flow” for this exercise, which requires the Qlik Sense Proxy Service to receive traffic from the public domain. If your Qlik Sense site is only accessible within a DMZ/corporate network, then you will need to setup on-premises data gateway. More information on this can be found here.

  1. Start a new flow by clicking at “+New flow”.
    Power automate new flow
  2. Then select “Schedules cloud flow”. This will open up a new flow window.
    Power automate new flow menu
  3. Give your flow a name and set the frequency of the flow. In the example shown below, the flow is set to run every 10 minutes.
    Power automate flow scheduler
  4. Then click on “Create”.
  5. You will then be taken to the flow editor. Click on “+New step”.
  6. From the prompt, search for “http” and select the HTTP action as shown in the picture below.
    Power automate http action flow
  7. Now select “GET” under the http method and enter the following address in URI field.
    https:// [YOUR_QLIK_SENSE_SERVER_ADDRESS]/[VIRTUAL_PROXY]/qps/user

    Please note: Please update the address with your own server details. There is no need for setting up any additional virtual proxy in Qlik Sense for this, as this endpoint will not require authentication. See the official documentations.

    Power automate http action flow settings
  8. Click on “+New step”.
  9. From the prompt, search for “variables” and select the “Initialize variable” action as shown in the picture below.
    Power automate variables settings
  10. Give your variable a name. e.g. statusCode.
  11. Set “Integer” as the variable type.
    Power automate variables settings
  12. Click on “+New step”.
  13. From the prompt, search for “condition” and select the “Condition Control” action as shown in the picture below.
    Power automate condition control
  14. This will give you condition flow configuration and two additional flows (one for when the condition returns TRUE and the other is for when it returns FALSE). Those flows are triggered based on the outcome of your condition. You will configure the condition first. Click on the first input box (in the “Condition” box) and select your variable (initialized in step 10).
  15. Pick “is not equal to” from the drop down in the middle.
  16. Type “200” in the last input box. Your condition control should look similar to the picture below.
    Power automate condition control settings
  17. Now click on “Add an action” in the “✔ if yes” flow.
    Power automate condition true flow
  18. From the prompt, search for “mail” and select the “Send an email notification (V3)” action as shown in the picture below.
    Power automate email action
  19. Enter the email address you wish to send notifications to in the “To” input field.
  20. Type in your notification subject in the “Subject” input field. E.g. Qlik Sense proxy error alert!
  21. Type in the email message in the “Body” input field.
    Note: you can use expressions, e.g. adding timestamp to the message to display when the error occurred – formatDateTime(utcNow(),'yyyy-MM-dd hh:mm:ss'). You can also include the JSON response or the response headers etc in the mail body.
    Optional steps 22-24
  22. Click on “Show advanced option” in the mail action.
  23. Click on “Attachment” and then select “Body” from the list.
  24. Type in a name in the “Attachment file Name” input box. E.g. Response-message.json.
    Power automate email action with attachments
  25. Press “Save”.

And the result

Make sure you test your flow and inspect the results. If everything goes well and the QPS service is working as intended, then you should not receive any email. The flow result should look like the image below.

Power Automate Flow
Power Automate Flow

You can change the condition value or logic to trigger the “Send email flow” and test the email notification. The email should contain the response content as JSON file attachment. That same information should also be in the email content/body (if you have followed the optional steps).

Email notification
Email notification

Enhancements

This is just simple example of what can be done with Power Automate. This approach can be enhanced and do more using the platform. E.g. You can send notification to Teams channel as well as sending email, you can store the outcome (fails and successes) straight into a database for further analysis of your environment’s uptime. You can even use node.js on the Qlik Sense server, have a Power Automate flow where you can trigger a PowerShell script (with the help of Node.js) to restart the service when there is an issue. There are lots of potential with this type of integration and it certainly can make administrative tasks much easier thus making the Qlik Sense platform more robust and reliable for your business users.

That is all for today. Thank you for reading. I hope you found this useful and this inspires people to come up with new ideas to automate more of Qlik Sense tasks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.