mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
f48ba11d4c
* Datasource/Cloudwatch: Adds support for Cloudwatch Logs * Fix rebase leftover * Use jsurl for AWS url serialization * WIP: Temporary workaround for CLIQ metrics * Only allow up to 20 log groups to be selected * WIP additional changes * More changes based on feedback * More changes based on PR feedback * Fix strict null errors
87 lines
2.0 KiB
Go
87 lines
2.0 KiB
Go
package tsdb
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/components/null"
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
// TsdbQuery contains all information about a query request.
|
|
type TsdbQuery struct {
|
|
TimeRange *TimeRange
|
|
Queries []*Query
|
|
Headers map[string]string
|
|
Debug bool
|
|
User *models.SignedInUser
|
|
}
|
|
|
|
type Query struct {
|
|
RefId string
|
|
Model *simplejson.Json
|
|
DataSource *models.DataSource
|
|
MaxDataPoints int64
|
|
IntervalMs int64
|
|
}
|
|
|
|
type Response struct {
|
|
Results map[string]*QueryResult `json:"results"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
type QueryResult struct {
|
|
Error error `json:"-"`
|
|
ErrorString string `json:"error,omitempty"`
|
|
RefId string `json:"refId"`
|
|
Meta *simplejson.Json `json:"meta,omitempty"`
|
|
Series TimeSeriesSlice `json:"series"`
|
|
Tables []*Table `json:"tables"`
|
|
Dataframes [][]byte `json:"dataframes"`
|
|
}
|
|
|
|
type TimeSeries struct {
|
|
Name string `json:"name"`
|
|
Points TimeSeriesPoints `json:"points"`
|
|
Tags map[string]string `json:"tags,omitempty"`
|
|
}
|
|
|
|
type Table struct {
|
|
Columns []TableColumn `json:"columns"`
|
|
Rows []RowValues `json:"rows"`
|
|
}
|
|
|
|
type TableColumn struct {
|
|
Text string `json:"text"`
|
|
}
|
|
|
|
type RowValues []interface{}
|
|
type TimePoint [2]null.Float
|
|
type TimeSeriesPoints []TimePoint
|
|
type TimeSeriesSlice []*TimeSeries
|
|
|
|
func NewQueryResult() *QueryResult {
|
|
return &QueryResult{
|
|
Series: make(TimeSeriesSlice, 0),
|
|
}
|
|
}
|
|
|
|
func NewTimePoint(value null.Float, timestamp float64) TimePoint {
|
|
return TimePoint{value, null.FloatFrom(timestamp)}
|
|
}
|
|
|
|
func NewTimeSeriesPointsFromArgs(values ...float64) TimeSeriesPoints {
|
|
points := make(TimeSeriesPoints, 0)
|
|
|
|
for i := 0; i < len(values); i += 2 {
|
|
points = append(points, NewTimePoint(null.FloatFrom(values[i]), values[i+1]))
|
|
}
|
|
|
|
return points
|
|
}
|
|
|
|
func NewTimeSeries(name string, points TimeSeriesPoints) *TimeSeries {
|
|
return &TimeSeries{
|
|
Name: name,
|
|
Points: points,
|
|
}
|
|
}
|