Skip to content

Instantly share code, notes, and snippets.

@rpendela
Created March 20, 2019 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpendela/fe8ba8900c75ac629595ec2a5f1061d8 to your computer and use it in GitHub Desktop.
Save rpendela/fe8ba8900c75ac629595ec2a5f1061d8 to your computer and use it in GitHub Desktop.
{
"trigger": {
"schedule": {
"interval": "60m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"dslogs-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"term": {
"beat.ip": "10.7.1.109"
}
},
{
"term": {
"levelname": "CRITICAL"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-60m"
}
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"notify-pagerduty": {
"throttle_period_in_millis": 300000,
"pagerduty": {
"description": "ATTENTION: critical logs found in last 1hour and triggered at {{ctx.execution_time}}",
"client_url": "https://kibana1.corp.mycompany.com/",
"attach_payload": true,
"account": "team1",
"contexts": [
{
"type": "link",
"href": "https://mycompany.pagerduty.com"
},
{
"type": "link",
"href": "https://mycompany.pagerduty.com",
"text": "View the incident on {{ctx.payload.link}}"
}
]
}
}
}
}
{
"trigger": {
"schedule": {
"interval": "60m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"dslogs-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"term": {
"beat.ip": "10.7.1.109"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-60m"
}
}
}
],
"should": [
{
"match_phrase": {
"levelname": "CRITICAL"
}
}
],
"minimum_should_match": 1
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"notify-pagerduty": {
"throttle_period_in_millis": 300000,
"pagerduty": {
"description": "ATTENTION: critical logs found in last 1hour and triggered at {{ctx.execution_time}}",
"client_url": "https://kibana1.corp.mycompany.com/",
"attach_payload": true,
"account": "team1",
"contexts": [
{
"type": "link",
"href": "https://mycompany.pagerduty.com"
},
{
"type": "link",
"href": "https://mycompany.pagerduty.com",
"text": "View the incident on {{ctx.payload.link}}"
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment