Skip to content

Instantly share code, notes, and snippets.

Avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
View am.conf.json
{
"template_files": {},
"alertmanager_config": {
"route": {
"receiver": "webhook_test",
"group_by": [
"alertname"
]
},
"templates": [],
@kylebrandt
kylebrandt / notes.md
Last active Apr 12, 2021
alert migration notes
View notes.md

Alert Migration Notes

List of things the migration does or will need to do

  • Load the dashboard alert from alert table and create rules in the alert_rule table
    • Translate conditions and queries into SSE for the alert_rule row
    • Translate other settings like NoData,FOR,Interval,alertRuleTags,(notifications?) for alert_rule row
    • Match Permissions of dashboard alert (create folders as needed):
      • Alerts will not have permissions, Folders will
      • If alert's dashboard has permissions, create corresponding folder to match permissions
@kylebrandt
kylebrandt / many_cc.http
Created Apr 6, 2021
Lots of Conditions
View many_cc.http
POST http://admin:admin@localhost:3000/api/alert-definitions/
Content-Type: application/json
{
"title": "classic many",
"condition": "G",
"data": [
{
"refId": "A",
@kylebrandt
kylebrandt / rule.http
Last active Apr 2, 2021
Changing Rule Post Example (predicatable pulse)
View rule.http
POST http://admin:admin@localhost:3000/ruler/grafana/api/v1/rules/ng-alert-demo
Content-Type: application/json
{
"name": "test-group2",
"interval": "10s",
"rules": [
{
"grafana_alert": {
"title": "pp query with SSE classic condition",
View rulerPostExample.http
POST http://admin:admin@localhost:3000/ruler/grafana/api/v1/rules/ng-alert-demo
Content-Type: application/json
{
"name": "test-group",
"interval": "10s",
"rules": [
{
"grafana_alert": {
"title": "prom query with SSE classic condition",
@kylebrandt
kylebrandt / cc.jpg
Last active Mar 5, 2021
CC and Translation Progress
@kylebrandt
kylebrandt / example.sh
Created Mar 3, 2021
evalOld using copy of settings column (jq/curl)
View example.sh
xclip -o -selection clipboard | jq '.conditions | { "conditions": . }' | curl -H 'Content-Type: application/json' -X POST --data-binary @- http://admin:admin@localhost:3000/api/alert-definitions/evalOld | jq -r '.instances[0]' | base64 -d > ~/tmp/af && arrow-cat ~/tmp/af
@kylebrandt
kylebrandt / put_update_alert.http
Created Feb 26, 2021
Classic Condition in SSE
View put_update_alert.http
PUT http://admin:admin@localhost:3000/api/alert-definitions/HH7cv0yMk
Content-Type: application/json
{
"id": 24,
"orgId": 1,
"title": "First CC Alert",
"condition": "B",
"data": [
{
@kylebrandt
kylebrandt / Conditions property in the settings column Grafana's alert table.json
Created Feb 23, 2021
Json Example of Same Alert Rule - Two conditions, pointing to the same query
View Conditions property in the settings column Grafana's alert table.json
"conditions": [
{
"evaluator": {
"params": [
0
],
"type": "gt"
},
"operator": {
"type": "and"
@kylebrandt
kylebrandt / couple_tests_error_keep_state.go
Last active Feb 16, 2021
Dashboard Alerting keep state issues
View couple_tests_error_keep_state.go
{
name: "pending -> error(keep) with for duration have passed",
expected: models.AlertStatePending,
applyFn: func(ec *EvalContext) {
ec.PrevAlertState = models.AlertStatePending
ec.Rule.ExecutionErrorState = models.ExecutionErrorKeepState
ec.Error = errors.New("test error")
ec.Rule.For = time.Minute * 5
ec.Rule.LastStateChange = time.Now().Add(-time.Minute * 20)
},