With the Engineered Monitoring Platform, you have the possibility to fetch data from REST APIs.
In this post we have a look at how you can fetch data from JIRA and display them on a dashboard.
STEP 1 – Preparations
First you will need to get the the JIRA credentials to access the API:
- API URL
- Username and Password/Token
In EMP you need the following Permissions:
- Dashboard Creator or Admin
- Credentials: Creator or Admin
- Query: User or Admin
In EMP, we go to “Tools >> Credentials” and add a new credentials entry with the name “JIRA_API”.
STEP 2 – Fetching the Query
With the credentials ready, we can now create a query to fetch data from the JIRA API.
In EMP got to “Tools >> Query” to open the Query Editor.
With the following EMP query we use our credentials and use a JIRA JQL query to fetch the data we want.
| source web
method="GET"
url=literal(credentials("JIRA_API").url)+"/2/search" # url would be something like https://<your-company>.atlassian.net/rest/api/
auth='basic_header'
username = credentials("JIRA_API").account
password = credentials("JIRA_API").password
headers=object(
'Content-Type', 'application/json; charset=UTF-8'
, 'accept', 'application/json'
)
# A filter query
body=`{"jql": "created >= -30d order by created DESC", "maxResults": 10} `
STEP 3 – Manipulating the Data
Now so far we only got a list of JIRA issues in our response, which is represented as a JSON structure.
Now this is not really useful to show on a dashboard. So what we do is using some commands to unbox the data we want from the JSON structure and format the data as we need it in a table.
Following is our enhanced query:
| source web
method="GET"
url=literal(credentials("JIRA_API").url)+"/2/search" # url would be something like https://<your-company>.atlassian.net/rest/api/
auth='basic_header'
username = credentials("JIRA_API").account
password = credentials("JIRA_API").password
headers=object(
'Content-Type', 'application/json; charset=UTF-8'
, 'accept', 'application/json'
)
# A filter query
body=`{"jql": "created >= -30d order by created DESC", "maxResults": 10} `
| unbox issues replace=true
| unbox issues replace=true
| rename
id="ID"
key="KEY"
self="URL"
| set
"PARENT_ID" = fields.parent.id
"PARENT_KEY" = fields.parent.key
"PARENT_URL" = fields.parent.self
"TITLE" = fields.summary
"ASSIGNEE" = fields.assignee.name
"ASSIGNEE_EMAIL" = fields.assignee.emailAddress
"REPORTER" = fields.reporter.name
"REPORTER_EMAIL" = fields.reporter.emailAddress
"STATUS" = fields.status.name
"CREATED" = fields.created
"UPDATED" = fields.updated
| remove expand, fields
| set
CREATED = timeparse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", CREATED)
UPDATED = timeparse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", UPDATED)
| formatfield
[fields, issues] = list
[CREATED, UPDATED] = date
[URL, PARENT_URL] = ['link', "Open", "button", "fa-external-link-square-alt", "blank"]
STEP 4 – Displaying it on a Dashboard
Finally we take above query and show it on a dashboard.
- In EMP go to “Tools >> Dashboard” and create a new dashboard.
- Open the dashboard and click the edit button
- Click the “Add Widget” button and select “Advanced >> Display Query Results”
- Copy and Paste your query into the Query Editor field.
- Save the widget.
- Your data should now be shown in the widget
Summary
Very well done! You have (hopefully) successfully shown some JIRA issues on your dashboard.
Now feel free to splurge on it and create 517 dashboards showing everything you ever stored in JIRA.