Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
akshatha9986
Contributor
Contributor

Python code for monitoring replication tasks and latency

Wanted python code for monitoring replication tasks using rest api and pushing them into newrelic.

Labels (2)
1 Solution

Accepted Solutions
deepaksahirwar
Creator II
Creator II

Dear @akshatha9986 ,

For monitoring Qlik replication tasks and latency, you can use the Qlik Replicate REST API to retrieve information about replication tasks and their status . You can write a Python script that periodically queries the REST API and pushes the data to New Relic using the New Relic Python Agent . Here is an example of how to use the Qlik Replicate REST API to retrieve replication task information:

Python

import requests

url = "https://<qlik_replicate_host>/api/v1/replication_tasks"
headers = {
"Authorization": "Bearer <access_token>",
"Content-Type": "application/json",
}

response = requests.get(url, headers=headers)
tasks = response.json()

# Extract the task information
for task in tasks:
task_name = task["name"]
task_status = task["status"]
task_latency = task["latency"]
# Push the task information to New Relic
# ...

You can replace <qlik_replicate_host> with the hostname of your Qlik Replicate instance and <access_token> with your OAuth 2.0 access token. The above code retrieves the replication task information and latency for all tasks in your Qlik Replicate instance.

 

If you found our response useful, we kindly ask you to click on “Accept as Solution”. This will aid other users in finding the answer more effortlessly.

Thank you! 😊

 

Regards,
Deepak

View solution in original post

4 Replies
mattdevdba
Luminary
Luminary

Hi. I wrote this blog sometime ago that should help. https://mattdevdba.medium.com/using-the-attunity-aem-rest-api-to-send-metrics-to-elastic-stack-c8ed4... the destination was Elasticsearch but you should be able to swap that out for New Relic and the code is in Python. Hope this helps.

dackr16
Contributor
Contributor

Well, nagios is a well-known one that I used for many years. I eventually started disliking it and created my own monitoring code (not in Python), but it works well for many people. Google around for nagios alternatives to see other popular systems

DesmondWOO
Support
Support

Hi @akshatha9986 ,

You can find an example program named example.py for reference under <Qlik Enterprise Manager Install Location>clients\python directory.

Regards,
Desmond

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!
deepaksahirwar
Creator II
Creator II

Dear @akshatha9986 ,

For monitoring Qlik replication tasks and latency, you can use the Qlik Replicate REST API to retrieve information about replication tasks and their status . You can write a Python script that periodically queries the REST API and pushes the data to New Relic using the New Relic Python Agent . Here is an example of how to use the Qlik Replicate REST API to retrieve replication task information:

Python

import requests

url = "https://<qlik_replicate_host>/api/v1/replication_tasks"
headers = {
"Authorization": "Bearer <access_token>",
"Content-Type": "application/json",
}

response = requests.get(url, headers=headers)
tasks = response.json()

# Extract the task information
for task in tasks:
task_name = task["name"]
task_status = task["status"]
task_latency = task["latency"]
# Push the task information to New Relic
# ...

You can replace <qlik_replicate_host> with the hostname of your Qlik Replicate instance and <access_token> with your OAuth 2.0 access token. The above code retrieves the replication task information and latency for all tasks in your Qlik Replicate instance.

 

If you found our response useful, we kindly ask you to click on “Accept as Solution”. This will aid other users in finding the answer more effortlessly.

Thank you! 😊

 

Regards,
Deepak