Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@kylebrandt
kylebrandt / dashboard.json
Created October 2, 2025 16:19
SQL Expressions Conversion To Full Long Example Dashboard
{
"__inputs": [
{
"name": "DS_MOCK",
"label": "Mock",
"description": "",
"type": "datasource",
"pluginId": "grafana-mock-datasource",
"pluginName": "Mock"
},
@kylebrandt
kylebrandt / DataplaneFAQ.md
Last active October 3, 2025 16:01
SQL Expressions and Dataplane DOC drafts

Dataplane FAQ

How does dataplane relate to Dataframes?

Dataplane adds a data typing layer on top of data frames. By analogy Dataplane Types are to dataframes as typescript is to javascript.

Specifically, a property is added to the dataframe to indicate its type with is made up of a kind and a format, for example "Timeseries Wide".

There are two properties attached to each data frame for this, frame.meta.type and frame.meta.typeversion.

@kylebrandt
kylebrandt / 0response.json
Last active September 19, 2025 14:52
sqlSchema endpoint example
HTTP/1.1 200 OK
Audit-Id: 5b82aaf1-4ba7-48bc-bb7b-94a7b89c6c5e
Cache-Control: no-store
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Date: Fri, 19 Sep 2025 14:51:41 GMT
Content-Length: 902
Connection: close
@kylebrandt
kylebrandt / README.md
Last active May 13, 2025 00:49
Audible Dashboard for fun (Sheets and SQL Expressions)

image

The queries

Panel: Main Sheet

SQL:

SELECT title, author, copyright, href, image, rating, series
FROM main
@kylebrandt
kylebrandt / genre.sql
Created May 12, 2025 19:33
Some Wide/Long SQL
/* Long
WITH movie_genre AS (
SELECT
A.title,
A.year,
B.Genre AS genre
FROM A
JOIN B ON A.imdb_id = B.imdb_id
),
genre_totals AS (
@kylebrandt
kylebrandt / screenshots.md
Last active April 30, 2025 15:59
SQL Expression Example Screenshots

Smooth Time Series (PromQL DS)

image

Trend line over Time Series (PromQL DS)

image

Aggregation and Math across Different Queries (Azure Metrics)

Calculate percentage of syn packages against total packets, per direction image

@kylebrandt
kylebrandt / time_funcs.go
Created April 1, 2025 18:33
Can't implement FunctionProvider
package sql
import (
"context"
"time"
mysql "github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
)
@kylebrandt
kylebrandt / sql_expr_basic_usage_chatgpt.md
Created March 27, 2025 14:05
Basic Usage of SQL Expressions in Grafana

📘 Basic Usage of SQL Expressions in Grafana

SQL expressions in Grafana let you perform lightweight SQL-like transformations on the results of other queries — directly within the panel. This is great for reshaping, renaming, filtering, and aggregating data without modifying the original datasource query.


🔧 How SQL Expressions Work

SQL expressions operate on the output of another query in the same panel, referenced by its query letter (e.g., A, B). These expressions are parsed and executed by Grafana — not sent to an external database.

@kylebrandt
kylebrandt / README.md
Last active March 14, 2025 17:02
SQL Expressions and Full Long (Written by ChatGPT)

Why *_full_long Formats Are Essential for Handling Label Sparsity

Overview

In Grafana, data coming from many sources includes sparse labels — meaning some series have label keys that others do not.
This is common in systems like Prometheus, OpenTelemetry, or SQL queries with GROUP BY.

However, traditional long formats (like time_series_long or numeric_long) do not preserve label sparsity correctly, leading to broken behaviors in visualization, alerts, and expressions.


@kylebrandt
kylebrandt / func.go
Created January 26, 2025 15:55
mysql_func
package sql
import (
"fmt"
mysql "github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
)
type SlothFunction struct{}