Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docs/greptimedb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
tags:
- datasource
---

# GreptimeDB plugins

The GreptimeDB package includes several plugins that provide comprehensive support for GreptimeDB in Perses dashboards.

## Datasource (`GreptimeDBDatasource`)

The GreptimeDB datasource enables connection between Perses and your GreptimeDB instance for SQL querying. It works with various visualization panels and supports SQL queries against the GreptimeDB HTTP SQL API (`POST /v1/sql`).

It supports the [proxy](https://perses.dev/perses/docs/concepts/proxy/) feature of Perses that allows to restrict the access to your data source.

See also technical docs related to this plugin:

- [Data model](./model.md#greptimedbdatasource)
- [Dashboard-as-Code Go lib](./go-sdk/datasource.md)

## Time Series Query (`GreptimeDBTimeSeriesQuery`)

The GreptimeDB time series query plugin enables executing SQL queries against your GreptimeDB database for time-based data visualization.

See also technical docs related to this plugin:

- [Data model](./model.md#greptimedbtimeseriesquery)
- [Dashboard-as-Code Go lib](./go-sdk/timeseries-query.md)

## Log Query (`GreptimeDBLogQuery`)

The GreptimeDB log query plugin enables querying log data stored in your GreptimeDB database using SQL.

See also technical docs related to this plugin:

- [Data model](./model.md#greptimedblogquery)
- [Dashboard-as-Code Go lib](./go-sdk/log-query.md)

## Trace Query (`GreptimeDBTraceQuery`)

The GreptimeDB trace query plugin enables querying trace data stored in your GreptimeDB database using SQL. It works with trace visualization panels such as [Trace Table](../tracetable/README.md) and [Tracing Gantt Chart](../tracingganttchart/README.md).

See also technical docs related to this plugin:

- [Data model](./model.md#greptimedbtracequery)
- [Dashboard-as-Code Go lib](./go-sdk/trace-query.md)
56 changes: 56 additions & 0 deletions docs/greptimedb/go-sdk/datasource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# GreptimeDB Datasource Go SDK

## Constructor

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/datasource"

var options []datasource.Option
datasource.GreptimeDB(options...)
```

Need a list of options. At least direct URL or proxy URL, in order to work.

## Default options

- None

## Available options

#### Direct URL

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/datasource"

datasource.DirectURL("http://localhost:4000")
```

Configure the access to the GreptimeDB datasource with a direct URL.

#### Proxy

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/datasource"

datasource.HTTPProxy("https://current-domain-name.io", httpProxyOptions...)
```

Configure the access to the GreptimeDB datasource with a proxy URL. More info at [HTTP Proxy](https://perses.dev/perses/docs/dac/go/helper/http-proxy).

## Example

```golang
package main

import (
"github.com/perses/perses/go-sdk/dashboard"

gtDs "github.com/perses/plugins/greptimedb/sdk/go/datasource"
)

func main() {
dashboard.New("GreptimeDB Dashboard",
dashboard.AddDatasource("greptimeMain", gtDs.GreptimeDB(gtDs.DirectURL("http://localhost:4000"))),
)
}
```
65 changes: 65 additions & 0 deletions docs/greptimedb/go-sdk/log-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# GreptimeDB Log Query Go SDK

## Constructor

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/log"

var options []log.Option
log.GreptimeDBLogQuery("SELECT * FROM greptime.public.logs LIMIT 100", options...)
```

Need to provide the SQL query expression and a list of options.

## Default options

- [Query()](#query): with the expression provided in the constructor.

## Available options

#### Query

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/log"

log.Query("SELECT * FROM greptime.public.logs WHERE severity_text = 'ERROR' LIMIT 100")
```

Define the SQL query expression.

#### Datasource

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/log"

log.Datasource("MyGreptimeDBDatasource")
```

Define the datasource the query will use.

## Example

```golang
package main

import (
"github.com/perses/perses/go-sdk/dashboard"
"github.com/perses/perses/go-sdk/panel"
panelgroup "github.com/perses/perses/go-sdk/panel-group"
"github.com/perses/plugins/greptimedb/sdk/go/query/log"
logstable "github.com/perses/plugins/logstable/sdk/go"
)

func main() {
dashboard.New("GreptimeDB Logs Dashboard",
dashboard.AddPanelGroup("Application Logs",
panelgroup.AddPanel("Recent logs",
logstable.LogsTable(),
panel.AddQuery(
log.GreptimeDBLogQuery("SELECT * FROM greptime.public.logs LIMIT 100"),
),
),
),
)
}
```
92 changes: 92 additions & 0 deletions docs/greptimedb/go-sdk/timeseries-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# GreptimeDB Time Series Query Go SDK

## Constructor

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/time-series"

var options []timeseries.Option
timeseries.GreptimeDBTimeSeriesQuery(`
SELECT time_window, loc,
max(max_temp) RANGE '1m' FILL LINEAR AS max_temp
FROM public.temp_alerts
WHERE time_window >= to_timestamp_millis(${__from})
AND time_window <= to_timestamp_millis(${__to})
ALIGN '30s' BY (loc)
ORDER BY time_window ASC
LIMIT 2000
`, options...)
```

Need to provide the SQL query expression and a list of options.

## Default options

- [Query()](#query): with the expression provided in the constructor.

## Available options

#### Query

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/time-series"

timeseries.Query(`
SELECT time_window, loc,
max(max_temp) RANGE '1m' FILL LINEAR AS max_temp
FROM public.temp_alerts
WHERE time_window >= to_timestamp_millis(${__from})
AND time_window <= to_timestamp_millis(${__to})
ALIGN '30s' BY (loc)
ORDER BY time_window ASC
LIMIT 2000
`)
```

Define the SQL query expression. `${__from}` and `${__to}` are replaced when the dashboard runs in Perses.

#### Datasource

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/time-series"

timeseries.Datasource("MyGreptimeDBDatasource")
```

Define the datasource the query will use.

## Example

```golang
package main

import (
"github.com/perses/perses/go-sdk/dashboard"
"github.com/perses/perses/go-sdk/panel"
panelgroup "github.com/perses/perses/go-sdk/panel-group"
"github.com/perses/plugins/greptimedb/sdk/go/query/time-series"
tsChart "github.com/perses/plugins/timeserieschart/sdk/go"
)

func main() {
dashboard.New("GreptimeDB Dashboard",
dashboard.AddPanelGroup("Metrics",
panelgroup.AddPanel("Max temperature",
tsChart.Chart(),
panel.AddQuery(
timeseries.GreptimeDBTimeSeriesQuery(`
SELECT time_window, loc,
max(max_temp) RANGE '1m' FILL LINEAR AS max_temp
FROM public.temp_alerts
WHERE time_window >= to_timestamp_millis(${__from})
AND time_window <= to_timestamp_millis(${__to})
ALIGN '30s' BY (loc)
ORDER BY time_window ASC
LIMIT 2000
`),
),
),
),
)
}
```
102 changes: 102 additions & 0 deletions docs/greptimedb/go-sdk/trace-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# GreptimeDB Trace Query Go SDK

## Constructor

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/trace"

var options []trace.Option
trace.GreptimeDBTraceQuery("SELECT * FROM public.opentelemetry_traces LIMIT 100", options...)
```

Need to provide the SQL query expression and a list of options.

## Default options

- [Query()](#query): with the expression provided in the constructor.

## Available options

#### Query

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/trace"

trace.Query("SELECT * FROM public.opentelemetry_traces WHERE trace_id = 'abc123' ORDER BY timestamp ASC")
```

Define the SQL query expression.

#### Datasource

```golang
import "github.com/perses/plugins/greptimedb/sdk/go/query/trace"

trace.Datasource("MyGreptimeDBDatasource")
```

Define the datasource the query will use.

## Example

### Trace Table

Use a trace list SQL query with the [Trace Table](../../tracetable/README.md) panel:

```golang
package main

import (
"github.com/perses/perses/go-sdk/dashboard"
"github.com/perses/perses/go-sdk/panel"
panelgroup "github.com/perses/perses/go-sdk/panel-group"
"github.com/perses/plugins/greptimedb/sdk/go/query/trace"
tracetable "github.com/perses/plugins/tracetable/sdk/go"
)

func main() {
dashboard.New("GreptimeDB Traces Dashboard",
dashboard.AddPanelGroup("Trace search",
panelgroup.AddPanel("Trace list",
tracetable.Chart(),
panel.AddQuery(
trace.GreptimeDBTraceQuery("SELECT * FROM public.opentelemetry_traces LIMIT 100"),
),
),
),
)
}
```

### Tracing Gantt Chart

Use a trace detail SQL query (with a `trace_id` filter) with the [Tracing Gantt Chart](../../tracingganttchart/README.md) panel:

```golang
package main

import (
"github.com/perses/perses/go-sdk/dashboard"
"github.com/perses/perses/go-sdk/panel"
panelgroup "github.com/perses/perses/go-sdk/panel-group"
"github.com/perses/plugins/greptimedb/sdk/go/query/trace"
tracinggantt "github.com/perses/plugins/tracingganttchart/sdk/go"
)

func main() {
dashboard.New("GreptimeDB Trace Timeline Dashboard",
dashboard.AddPanelGroup("Trace details",
panelgroup.AddPanel("Trace timeline",
tracinggantt.Chart(),
panel.AddQuery(
trace.GreptimeDBTraceQuery(`
SELECT * FROM public.opentelemetry_traces
WHERE trace_id = 'abc123abc123abc123abc123abc123ab'
ORDER BY timestamp ASC
`),
),
),
),
)
}
```
Loading
Loading