Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@kylebrandt
kylebrandt / duration_response.json
Created April 27, 2020 19:35
Dataframe Response: Has Duration
{"results":{"A":{"refId":"A","series":null,"tables":null,"dataframes":["QVJST1cxAAD/////sBAAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEDAAoADAAAAAgABAAKAAAACAAAAJQAAAADAAAAVAAAACgAAAAEAAAA3O///wgAAAAMAAAAAQAAAEEAAAAFAAAAcmVmSWQAAAD87///CAAAABQAAAAKAAAAbWFueV90eXBlcwAABAAAAG5hbWUAAAAAJPD//wgAAAAkAAAAGQAAAHsiY3VzdG9tIjp7IkhpIjoidGhlcmUifX0AAAAEAAAAbWV0YQAAAAAdAAAAFA8AANQMAAAYDAAAlAsAACALAACcCgAAKAoAAKQJAAAwCQAArAgAADQIAAC0BwAARAcAAMQGAABUBgAA1AUAAGQFAADkBAAAbAQAAOwDAAB8AwAA/AIAAJgCAAAcAgAAtAEAAEwBAADUAAAAbAAAAAQAAACu8///FAAAAEAAAABAAAAAAAASAUAAAAABAAAABAAAAPTw//8IAAAAFAAAAAgAAABkdXJhdGlvbgAAAAAEAAAAbmFtZQAAAAAAAAAAuvv//wAAAwAIAAAAZHVyYXRpb24AAAAA1vH//xQAAABAAAAAQAAAAAAAABJAAAAAAQAAAAQAAABY8f//CAAAABQAAAAIAAAAZHVyYXRpb24AAAAABAAAAG5hbWUAAAAAAAAAAB78//8AAAMACAAAAGR1cmF0aW9uAAAAAHb0//8UAAAASAAAAEgAAAAAAAoBSAAAAAEAAAAEAAAAvPH//wgAAAAcAAAAEwAAAG51bGxhYmxlX3RpbWVzdGFtcHMABAAAAG5hbWUAAAAAAAAAAIr8//8AAAMAEwAAAG51bGxhYmxlX3RpbWVzdGFtcHMArvL//xQAAABAAAAAQAAAAAAAAApAAAAAAQAAAAQAAAAw8v//CAAAABQAAAAKAAAAdGltZXN0YW1wcwAABAAAAG5h
@kylebrandt
kylebrandt / notes.md
Created June 2, 2020 14:45
frame in grafana encoding notes

Frame encoding within Grafana

By Destination

Case Backend Plugin:

  • If going to frontend leave it encoded
  • If going to alerting, decode it

Case Core (Internal) Datasource:

package azuremonitor
import (
"encoding/json"
"fmt"
"time"
"github.com/grafana/grafana-plugin-sdk-go/data"
)
@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)
@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 / 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 / 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 / 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 / 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"