Skip to content

Instantly share code, notes, and snippets.

Avatar
🔨
🦥

Kyle Brandt kylebrandt

🔨
🦥
View GitHub Profile
@kylebrandt
kylebrandt / req.http
Last active Nov 17, 2020
ang_api_req 3
View req.http
###
GET http://admin:admin@localhost:3000/api/alert-definitions
###
@alertId = 16
###
@kylebrandt
kylebrandt / cmd.sh
Created Jun 26, 2020
random_insights_bench
View cmd.sh
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)
View insights-metrics.go
package azuremonitor
import (
"encoding/json"
"fmt"
"time"
"github.com/grafana/grafana-plugin-sdk-go/data"
)
@kylebrandt
kylebrandt / notes.md
Created Jun 2, 2020
frame in grafana encoding notes
View notes.md

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 Apr 27, 2020
Dataframe Response: Has Duration
View duration_response.json
{"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 Apr 27, 2020
Why data frames notes
View why_df_notes.md

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.
@kylebrandt
kylebrandt / why_df_notes.md
Created Apr 27, 2020
Why data frames notes
View why_df_notes.md

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.
@kylebrandt
kylebrandt / output.txt
Created Mar 30, 2020
sparse long wide print output
View output.txt
=== RUN TestLongToWide/sparse:_one_value,_two_factor
Name: long_to_wide_test
Dimensions: 4 Fields by 6 Rows
+-------------------------------+---------------------+---------------------+-------------------------+
| Name: Time | Name: Values Floats | Name: Animal Factor | Name: Location |
| Labels: | Labels: | Labels: | Labels: |
| Type: []time.Time | Type: []float64 | Type: []string | Type: []string |
+-------------------------------+---------------------+---------------------+-------------------------+
| 2020-01-02 03:04:00 +0000 UTC | 1 | cat | Florida |
| 2020-01-02 03:04:00 +0000 UTC | 2 | sloth | Central & South America |
@kylebrandt
kylebrandt / gist:b17ff133127b88165fd22a65a0424e81
Last active Feb 14, 2020
wip wide/tall df graphing issue
View gist:b17ff133127b88165fd22a65a0424e81

Support Graphing of Long (a.k.a. Tall) and Wide Format Time Series Dataframes

Use Case

Currently our SQL plugins derive things from the special names of the columns. Instead we can use more conventional Long and Wide formats and derive the format from the schema. This will result in a more conventional SQL experience for users. The amount of code plugin authors need to create will be reduced.

Taking a MySQL Example:

SELECT
You can’t perform that action at this time.