Skip to content

Instantly share code, notes, and snippets.

@kylebrandt kylebrandt/bosun.json5
Last active Jan 25, 2019

Embed
What would you like to do?
Bosun VSCode Snippets
{
// Place your snippets for bosun here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"escount": {
"prefix": "escount",
"body": [
"escount(${1:indexer}, \"${2:keysCSV}\", ${3:filter}, \"${4:bucketDuration}\", \"${5:startDuration}\", \"${6:endDuration}\")"
]
},
"prom": {
"prefix": "prom",
"body": [
"prom(\"${1:metric}\", \"${2:groupByTagsCSV}\", \"${3:filter}\", \"${4:agType}\", \"${5:stepDuration}\", \"${6:startDuration}\", \"${7:endDuration}\")"
]
},
"promVars": {
"prefix": "promVars",
"body": [
"\\$${1:metric} = \"${2:metricName}\"",
"\\$${3:tags} = \"${4:tagsCSV}\"",
"\\$${5:filter} = \"${6:filterVal}\"",
"\\$${7:agg} = \"${8:sum}\"",
"\\$${9:step} = \"${10:1m}\"",
"",
"prom(\\$${1:metric}, \\$${3:tags}, \\$${5:filter}, \\$${7:agg}, \\$${9:step}, \"${11:10m}\", \"$12\")"
]
},
"promrate": {
"prefix": "promrate",
"body": [
"promrate(\"${1:metric}\", \"${2:groupByTagsCSV}\", \"${3:filter}\", \"${4:agType}\", \"${5:rateStepDuration}\", \"${6:stepDuration}\", \"${7:startDuration}\", \"${8:endDuration}\")"
]
},
// template Stuff
"tplLeftJoinTable": {
"prefix": "tplLeftJoinTable",
"body": [
"<h3>${1:tableTitle}</h3>",
"{{ \\$joinResult := .LeftJoin .Alert.Vars.${2:myVarForNumberSet1} .Alert.Vars.${3:myVarForNumberSet2} }}",
"{{ if notNil \\$joinResult }}",
" <table>",
" <tr>",
" <th>${4:columnTitle1ForATag}</th>",
" <th>${5:columnTitle2ForValue1}</th>",
" <th>${6:columnTitle3ForValue2}</th>",
" </tr>",
" {{ range \\$x := \\$joinResult }}",
" {{ \\$${7:val1} := index \\$x 0}}",
" {{ \\$${8:val2} := index \\$x 1}}",
" <!-- Filter Results to Match Context of Alert -->",
" {{ if eq \\$${7:val1}.Group.${9:tagToMatch} \\$.Group.${9:tagToMatch} }}",
" <tr>",
" <td>{{ \\$${7:val1}.Group.${10:aTag} }}</td>",
" <td>{{ \\$${7:val1}.Value }}</td>",
" <td>{{ \\$${8:val2}.Value }}</td>",
" </tr>",
" {{ end }}",
" {{ end }}",
"{{ else }}",
" Error Creating Table: {{ .LastError }}",
"{{ end }}"
]
},
// Sections
"stackTemplate": {
"prefix": "stackTemplate",
"body": [
"template ${1:my.template} {",
" subject = `{{.Last.Status}}: ${2:usefulStuff}`",
" body = `{{template \"header\" .}}",
" ",
" ${3:moreUsefulStuff}",
" ",
" {{template \"previous.incidents\" . }}`",
"}"
]
},
"lookupTable": {
"prefix": "lookupTable",
"body": [
"lookup ${1:tableName} {",
" entry ${2:tagK1}=${3:someGlob1},${4:tagK2}=${5:someGlob1} {",
" ${6:key1} = ${7:someValue1}",
" ${8:key1} = ${9:someValue2}",
" }",
" entry ${2:tagK1}=*,${4:tagK1}=* {",
" ${6:key1} = ${10:defValue1}",
" ${8:key2} = ${11:defValue2}",
" }",
"}",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.