Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@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"
)
@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:

@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 / why_df_notes.md
Last active April 27, 2020 14:23
Why data frames notes

Why data frames notes

Grafana's "wide tent" philosophy means we want Grafana to work with our users' data, and not make our users work to use Grafana. The data frame structure is a concept borrowed from data analysis like R and Pandas to allow us to do this.

Data frames allow users' data to be more accurately represented and with less effort.

  • The data binding throughout Grafana's is now shared. Data moved between Grafana's backend plugins, Grafana server, and frontend is now less destructive. The means there is less data munging and more supported data types such as time, nullable types, various number types and other primitives.
  • Time series data can be returned in different shapes that match those more commonly found.
  • Time series and table data now exist in the same structure.
  • Tables exist in the same structure as time series.