Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@kylebrandt
kylebrandt / notes.md
Last active November 17, 2021 13:32
Data source Info / Ref Notes

Some Notes on Data source Info / Data source Ref:

  • Terms I'm using for these notes:

    • DatasourceRef: is model that includes (uid+type), is saved by dashboards and alerting (note: alerting is current UID only)
    • DatasourceInfo: is full information that a datasource neededs to execute a request, and can be looked up by the Ref
  • Contexts:

    • Alerting: The Ref is saved. Alerts run as a service, so in this context there is no user (although perhaps there should be a service user or role). Therefore for saved alerts run by the service, authorization is done at creation time, not run time - (as users would not want alerts to stop working if a user is removed).
    • Query API: Runtime, in this context there is a user
  • Main Question:

@kylebrandt
kylebrandt / ds_notes.md
Last active January 26, 2022 13:58
Datasource Object Notes

Datasource Object Variations (Backend)

SQL Table (MySQL)

mysql> desc data_source;
+---------------------+--------------+------+-----+---------+----------------+
| Field               | Type         | Null | Key | Default | Extra          |
+---------------------+--------------+------+-----+---------+----------------+
| id                  | bigint(20)   | NO   | PRI | NULL    | auto_increment |
@kylebrandt
kylebrandt / intentAPICollabSession2022_02_04.diff
Created February 7, 2022 13:28
Intent API Collab Session 2022_02_04 diff
diff --git a/internal/components/datasource/schema.go b/internal/components/datasource/schema.go
index 98a29197ec..d75330be5c 100644
--- a/internal/components/datasource/schema.go
+++ b/internal/components/datasource/schema.go
@@ -82,6 +82,29 @@ func newDataSourceJSONKernel(lin thema.Lineage) kernel.InputKernel {
return jdk
}
+// TODO:
+// What is the schema (constraints) on []DataSource
@kylebrandt
kylebrandt / ts.md
Last active April 27, 2022 14:12
Formats Examples As Table

Frame Examples - Time Series Kind

Basic Example

This demonstrates the same set of two time series in all formats to serve as an introduction.

Wide

Type - Time
Name - T
Labels - nil
Type - Number
Name - cpu
Labels - {"host": "a"}
Type - Number
Name - cpu
Labels - {"host": "b"}
@kylebrandt
kylebrandt / images.md
Created August 28, 2023 18:15
Benchmark executedQueryString

Before (left), After (Right) image

image

Record Queries Multi

Recorded Queries will record multiple metrics, identified by labels, if the input data is numeric dataplane data.

Numeric dataplane data comes:

  • directly from a datasource, prometheus instant queries are an example
  • Server Side Expressions Reduce operation results (which can takes various forms of time series data as input)

Example 1

@kylebrandt
kylebrandt / pr.diff
Created October 13, 2023 14:24
pr.diff
diff --git a/go.mod b/go.mod
index 7534de9cfc..41d10ed8b3 100644
--- a/go.mod
+++ b/go.mod
@@ -124,7 +124,7 @@ require (
gopkg.in/mail.v2 v2.3.1 // @grafana/backend-platform
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // @grafana/alerting-squad-backend
- xorm.io/builder v0.3.6 // @grafana/backend-platform
+ xorm.io/builder v0.3.6 // indirect; @grafana/backend-platform
@kylebrandt
kylebrandt / example commands.md
Last active January 22, 2024 20:11
Prom Query Label Matcher Replacement
# ./pp <query> <scope> <aggregate_group_by> <func_string_replacements:funcName,argIdx,currentValue,newValue>...
# aggregate_group_by is optional

$ ./pp  'up{foo="baz",a="q"}' '{a=~"z"}'
up{a=~"z",foo="baz"}

$ ./pp 'up{foo="baz",a="q"}' '{a=~"z",c="z"}' 
up{a=~"z",c="z",foo="baz"}
@kylebrandt
kylebrandt / peakq.http
Last active February 6, 2024 14:20
peakq http
### Render a Basic template with POST
POST http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/render?var-metricName=up
Content-Type: application/json
Accept: application/json
{
"title": "Test",
"vars": [
{
"key": "metricName",