Trino Log Query Go SDK
Constructor#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
var options []log.Option
log.TrinoLogQuery("SELECT event_time AS timestamp, level, message FROM app_logs ORDER BY event_time DESC LIMIT 1000", options...)Need to provide the SQL query expression and a list of options.
Default options#
- Query(): with the expression provided in the constructor.
Available options#
Query#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.Query("SELECT event_time AS timestamp, level, message FROM app_logs ORDER BY event_time DESC LIMIT 1000")Define the SQL query expression.
Datasource#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.Datasource("MyTrinoDatasource")Define the datasource the query will use.
Catalog and Schema#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.Catalog("iceberg")
log.Schema("analytics")Set the catalog and schema sent as X-Trino-Catalog and X-Trino-Schema.
Session Properties#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.SessionProperties("query_max_run_time=5m")Set name=value session properties, separated by commas or line breaks, sent as X-Trino-Session.
Source#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.Source("perses")Set the source label sent as X-Trino-Source.
Routing Group#
import log "github.com/perses/plugins/trino/sdk/go/query/log"
log.RoutingGroup("adhoc")Set the routing group sent as X-Trino-Routing-Group, used by Trino Gateway.
Example#
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"
trinoquery "github.com/perses/plugins/trino/sdk/go/query/log"
logstable "github.com/perses/plugins/logstable/sdk/go"
)
func main() {
dashboard.New("Trino Dashboard",
dashboard.AddPanelGroup("Logs",
panelgroup.AddPanel("Application logs",
logstable.LogsTable(),
panel.AddQuery(
trinoquery.TrinoLogQuery(`
SELECT event_time AS timestamp, level, message
FROM app_logs
WHERE event_time >= TIMESTAMP '{start}'
ORDER BY event_time DESC
LIMIT 1000
`, trinoquery.Catalog("iceberg"), trinoquery.Schema("analytics")),
),
),
),
)
}
