Skip to content

Instantly share code, notes, and snippets.

@seantrane
Created November 11, 2024 11:36
Show Gist options
  • Save seantrane/cdef946e4fb87150451db954ff3caad5 to your computer and use it in GitHub Desktop.
Save seantrane/cdef946e4fb87150451db954ff3caad5 to your computer and use it in GitHub Desktop.
New Relic snippets

New Relic snippets

Alert Workflows

Email Notification

  • Email subject:

    [{{ priority }}-{{ state }}] {{#replace "/query.*minutes on/" annotations.title.[0]}}-{{else}}{{entitiesData.names}}{{/replace}}
  • Custom Details (optional):

    Issue Title: {{ issueTitle }}
    Issue Description: {{ annotations.description }}
    Alert Policy Names: {{ accumulations.policyName }}
    Alert Condition Names: {{ accumulations.conditionName }}
    Workflow Name: {{ workflowName }}
    Issue Source: {{ accumulations.source }}
    Impacted Entities Names: {{ entitiesData.names }}
    Issue Is Correlated: {{ isCorrelated }}
    Issue Page URL: {{ issuePageUrl }}
    Issue Created At: {{ issueCreatedAtUtc }}
    Issue Activated At: {{ issueActivatedAtUtc }}
    Issue Closed At: {{ issueClosedAtUtc }} 
    Issue ID: {{ issueId }}
    Issue Priority: {{ priority }}
    Issue Priority text: {{ priorityText }}
    Issue State: {{ state }}
    Issue state text: {{ stateText }}
    Issue Status: {{ status }}

ServiceNow Notification

  • Short description:

    {{#replace "/query.*minutes on/" annotations.title.[0]}}-{{else}}{{entitiesData.names}}{{/replace}}
  • Description:

    Issue Title: {{ issueTitle }}
    Issue Description: {{ annotations.description }}
    Alert Policy Name: {{ accumulations.policyName }}
    Alert Condition Name: {{ accumulations.conditionName }}
    Workflow Name: {{ workflowName }}
    Issue Source: {{ accumulations.source }}
    Impacted Entities Names: {{ entitiesData.names }}
    Issue Page URL: {{ issuePageUrl }}
    Issue Created At: {{  issueCreatedAt }}
    Issue Closed At: {{  issueClosedAt }}
    Issue ID: {{ issueId }}
    Issue Priority: {{ priority }}
    Issue State: {{ state }}
    Issue Duration: {{  issueDurationText }}
  • Urgency:

    {{#eq 'LOW' priority}}3{{else eq 'MEDIUM' priority}}2{{else}}1{{/eq}}

Data Enrichment

Critical Monitor Fail Rate, timeline

select (filter(uniqueCount(location), where result = 'FAILED') / uniqueCount(location)) * 100 as 'Fail Rate' 
from SyntheticCheck 
where monitorName in {{entitiesData.names}} 
limit 10 
since 6 hours ago 
timeseries 
facet monitorName

Critical Monitor Error Messages

select count(error) 
from SyntheticCheck 
where result = 'FAILED' and monitorName like '%#critical' 
limit 20 
since 6 hours ago 
facet 
  capture(monitorName, r'(?P<Monitor>[^#]+) #.*'),
  error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment