Reporting

Can Splunk generate a comment on a Jira ticket?

bennett66
Engager

The Question:
How do I get Splunk to add a comment to an existing Jira issue?

Ideally I want to have a Splunk form where a user inputs a Jira issue number and a search query. Once a day Splunk would count how many times that search query returned results and attach it to the Jira issue.

What I know:
Add-on for Jira. I've looked at this plugin but I can't see any functionality that lets me comment on an existing Jira ticket. Please correct me if I'm wrong.

Email. Jira does support adding comments from email, but I wanted to look for an easier method before going down this path.

Tags (3)
1 Solution

bennett66
Engager

Thanks to @mlf and @vinitatsky for pointing me in the right direction. Here's what I ended up doing.
1: Create a limited user account on Jira that can only comment on tickets in the appropriate project.
2: Setup a form in Splunk that aggregates data based on a string.
3: Each day execute a script that gathers the data from Splunk and sends it to the Jira API.
- Jira offers excellent tutorials for using the API, I followed THIS ONE.

My bash command to update a Jira issue (replace fields as necessary):

> curl -D- -u <my-username> -X POST --data @JSON.txt -H "Content-Type:application/json" https://<my-company>/jira/rest/api/2/issue/<Jira-Issue>/comment

Contents of JSON.txt file

{
    "body": "This is a comment sent from curl."
}

View solution in original post

bennett66
Engager

Thanks to @mlf and @vinitatsky for pointing me in the right direction. Here's what I ended up doing.
1: Create a limited user account on Jira that can only comment on tickets in the appropriate project.
2: Setup a form in Splunk that aggregates data based on a string.
3: Each day execute a script that gathers the data from Splunk and sends it to the Jira API.
- Jira offers excellent tutorials for using the API, I followed THIS ONE.

My bash command to update a Jira issue (replace fields as necessary):

> curl -D- -u <my-username> -X POST --data @JSON.txt -H "Content-Type:application/json" https://<my-company>/jira/rest/api/2/issue/<Jira-Issue>/comment

Contents of JSON.txt file

{
    "body": "This is a comment sent from curl."
}

mlf
Path Finder

Recent versions of Jira have a REST API. At a high level you would just need a scheduled search to pass it's results to a script that calls the Jira API to add the comment to the ticket. That said, the last time I played with Jira was several major versions ago, so I don't have the details necessary for the script itself.

vinitatsky
Communicator

In JIRA 6.2, you can use below URLs to check custom fields and their IDs (After successful Sign-in)
http://JIRA_HOST/rest/api/2/field

To update JIRA ticket ticket, you can refer below JSON. Make sure to use correct custom field ID.

URL - http://JIRA_HOST/rest/api/2/issue/
Method - PUT
Example JSON BODY :
{
"fields": {
"resolution":{"name":"Fixed"},
"assignee":{"name":"assignee_name"},

"customfield_10103":{"value":"Test Comment"},

},
"update": {
        "comment": [ { "add": { "body": "JIRA ticket is updated" } } ]
}

}

You can make this call using a Python script, which can be triggered from Splunk.

Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...