Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@kylebrandt
kylebrandt / example.sh
Created March 3, 2021 20:11
evalOld using copy of settings column (jq/curl)
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 February 26, 2021 12:39
Classic Condition in SSE
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 February 23, 2021 18:10
Json Example of Same Alert Rule - Two conditions, pointing to the same query
"conditions": [
{
"evaluator": {
"params": [
0
],
"type": "gt"
},
"operator": {
"type": "and"
@kylebrandt
kylebrandt / couple_tests_error_keep_state.go
Last active February 16, 2021 21:11
Dashboard Alerting keep state issues
{
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)
},
@kylebrandt
kylebrandt / panel.json
Last active December 15, 2020 15:17
Simpler Data source query Alert Def Post Example
POST http://admin:admin@localhost:3000/api/alert-definitions/
Content-Type: application/json
{
"name": "Example Alert POST",
"condition": {
"refId": "C",
"interval": 10,
"queriesAndExpressions": [
{
@kylebrandt
kylebrandt / main.go
Created December 4, 2020 20:46
random time zone go illustrations
package main
import (
"fmt"
"time"
)
func main() {
utc6 := time.FixedZone("UTC+6", 6*3600)
utc7 := time.FixedZone("UTC+7", 7*3600)
@kylebrandt
kylebrandt / req.http
Last active November 17, 2020 13:19
ang_api_req 3
###
GET http://admin:admin@localhost:3000/api/alert-definitions
###
@alertId = 16
###
@kylebrandt
kylebrandt / cmd.sh
Created June 26, 2020 14:29
random_insights_bench
benchcmp <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkOldInsights)$' -v | sed 's/BenchmarkOldInsights/BenchmarkInsightsMetricsResultToFrame/g') <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkInsightsMetricsResultToFrame)$' -v)
package azuremonitor
import (
"encoding/json"
"fmt"
"time"
"github.com/grafana/grafana-plugin-sdk-go/data"
)