Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROB-837] Pagerduty + JSM ticket support #334

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Avi-Robusta
Copy link
Contributor

Enhanced Investigation Links for PagerDuty & Jira Service Management

Holmes now supports adding investigation links directly into PagerDuty and Jira Service Management tickets. This includes tools for generating Loki log links and Grafana dashboard links automatically.


Jira Service Management Example

To initiate an investigation and automatically post a comment with relevant links in a Jira Service Management ticket, run:

poetry run python3 holmes.py investigate ticket \ 
    --source jira-service-management \
    --ticket-url "MY_JIRA_URL_HERE" \
    --ticket-username "MY_EMAIL" \            
    --ticket-api-key "KEY_HERE" \
    --ticket-id "SUP-2"  \
    "QUERY HERE" # Example: "Generate Loki and Grafana links for this issue"

This will:

  • Retrieve the issue from Jira Service Management.
  • Generate Loki log and Grafana dashboard links.
  • Automatically post the results as a comment on the Jira Service Management ticket.

Example Output in Jira Service Management

Jira Output

PagerDuty Example

To run an investigation for a PagerDuty incident and add the results as a note:

poetry run python3 holmes.py investigate ticket \
    --source pagerduty \
    --ticket-api-key "KEY_HERE" \
    --ticket-username "MY_EMAIL" \
    --ticket-id "INCIDENT_ID_HERE" \
    "QUERY HERE" # Example: "Generate Loki and Grafana links for this issue"

This will:

  • Retrieve the incident details from PagerDuty.
  • Generate Loki log and Grafana dashboard links.
  • Automatically add the results as a note to the incident.

Example Output in PagerDuty

PagerDuty Output

arikalon1
arikalon1 previously approved these changes Mar 19, 2025
Copy link
Contributor

@arikalon1 arikalon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

Left some comments, nothing is considered a blocker IMO

"""
Extracts and formats the issue description.
"""
description_blocks = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this logic the same for both Jira and JSM?

description = self.extract_description(jira_issue)
return self.convert_to_issue(jira_issue, description)
except requests.RequestException as e:
raise ConnectionError(f"Failed to fetch Jira ticket {id}") from e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be jsm ticket?

headers={"Accept": "application/json"},
)
response.raise_for_status()
jira_issue = response.json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsm_issue?

import logging


class ListAndBuildGrafanaDashboardURLs(Tool):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @aantn also implemented this
Are you two synced on this?

label_key = "pod" if resource_type == "pod" else "app"

# Correct JSON structure to match the expected URL format
expected_query_params = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for the POC, but do you think we can make it completely generic?
i.e., let the llm build the loki query on it's own, to get link to logs on any resource.
This worked very well with OpenSearch, but I'm not familiar enough with Loki

return
output_instructions = []
# Validate Jira details if source is Jira Service Management
if source == SupportedTicketSources.JIRA_SERVICE_MANAGEMENT:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider moving the creation if/else to another place, to prevent a huge if/else here
So this code doesn't have any source-specific code. (Just a thought)
So, it would be something like:

source_handler = SourceFactory.create_source(type, params)
   try:
        issue_to_investigate = source_handler.fetch_issue(id=ticket_id)
        if issue_to_investigate is None:
            raise Exception(f"Issue {ticket_id} Not found")
    except Exception as e:
   ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants