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!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...