Skip to content

A helper function to redirect Grafana drill down links into Instana

License

Notifications You must be signed in to change notification settings

flyingbarron/GrafanaRedirectInstana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Grafana redirect to Instana

A helper function to redirect Grafana drill down links into Instana

The purpose of this function is to extend the Instana plugin for Grafana and add a new feature - drill down from a Grafana graph to the Instana object dashboard.

The problem

The current problem is that an Instana dashboard URL requires the snapshotId of the object, which is not known by Grafana. The timeseries Grafana collects from Instana only has the object name (FQDN in the case of hosts).

Note that as of October 2021, this function only works on entities of type entity.host and entity.python.app

An example of a dashboard URL is https://<instanaHostURL>/#/physical/dashboard?snapshotId=<snapshotId>

After setting up the Grafana plugin for Instana (per https://grafana.com/grafana/plugins/instana-datasource/) you can create Grafana dashboards which show information about hosts monitored by Instana.

image

You can now edit your widget to add a drill down link:

image

Scroll to the bottom of the sidebar and click "Add link" in Data links.

What we would like to do now is add a link in the format of https://<instanaHostURL>/#/physical/dashboard?snapshotId=<snapshotId>

But as you can see, snapshotId is not one of the available fields:

image

The solution is to create a helper function which will recieve the Series Name (in the case of hosts this is the FQDN), translate that to the most recent snapshotId and redirect the browser to the Instana server.

The code shared in this repository does this.

The solution

The solution assumes that it will receive 3 parameters:

  1. instanaURL - the base URL of the Instana backend (https://myInstanaserver)
  2. instanaAPIToken - the API token to query the Instana REST API (highly recommended you use a token with limited and read-only access)
  3. fqdn - the FQDN of the host you want to view in Instana

The rest of this document will explain how to use this code as an IBM Cloud Function:

Create an IBM Cloud Function using the UI

  1. Login to https://cloud.ibm.com/functions/actions and create a new action by clicking "Create"
  2. Create an entity of type "Action"

image

  1. Create an action with the Python runtime and give it whatever name you want.

image

  1. Paste the content of the file (redirectInstana.py) into the online editor and save the file.

image

  1. In the "Parameters" tab, add the instanaURL and instanaAPIToken values and save.

image

  1. In the "Endpoints" tab, click the "Enable as Web Action" checkbox and save. Note/record the value of the public HTTP endpoint image

At this point you can test your function by running the command line instruction:

curl https://<thePublicFunctionEndpoint>.json?fqdn=<Hostname.domain>

and getting, as a result something like this:

{
  "headers": {
    "location": "https://<instanaServer>/#/physical/dashboard?snapshotId=<snapshotId>"
  },
  "statusCode": 302
}%

Note that the suffix .json was added to the function to display the HTTP response in your CLI window. This is not necessary in a browser.

If you enter the function in your browser (with or without the .json suffix), you will be redirected to the same location.

Returning to the Grafana dashboard, you can now create a drill down link which will call the function in a new browser tab and open the Instana dashboard on the host.

image

For a VM/host use the format: https://<endpoint>/redirectInstana?fqdn==${__series.name}

For a Python application use the format: https://<endpoint>/redirectInstana?plugin=python&python_name=${__series.name}

About

A helper function to redirect Grafana drill down links into Instana

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages