Documentation ¶
Index ¶
- type Config
- type Datum
- type Instance
- func (i *Instance) GetLabelValues(ctx context.Context, searchTerm string) ([]string, error)
- func (i *Instance) GetMetrics(ctx context.Context, queries []Query, resolution string, ...) (*Metrics, error)
- func (i *Instance) GetTableData(ctx context.Context, queries []Query, timeEnd int64) (map[string]map[string]string, error)
- func (i *Instance) GetVariable(ctx context.Context, label, query, queryType string, timeStart, timeEnd int64) ([]string, error)
- type Metric
- type Metrics
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string `json:"name"` DisplayName string `json:"displayName"` Description string `json:"description"` Home bool `json:"home"` Address string `json:"address"` Username string `json:"username"` Password string `json:"password"` Token string `json:"token"` }
Config is the structure of the configuration for a single Prometheus instance.
type Datum ¶
Datum is the structure of a single data point of a metric. The y value must be a pointer, because when the value is NaN we can not set the value (NaN in the JSON representation will throw an error). For that NaN values will always be null.
type Instance ¶
type Instance struct { Name string // contains filtered or unexported fields }
Instance represents a single Prometheus instance, which can be added via the configuration file.
func (*Instance) GetLabelValues ¶
GetLabelValues returns all label values for a configured Prometheus instance. These labels are used to show the user a list of suggestions for his entered query. The returned label values from the Prometheus API are cached for one hour.
func (*Instance) GetMetrics ¶
func (i *Instance) GetMetrics(ctx context.Context, queries []Query, resolution string, timeStart, timeEnd int64) (*Metrics, error)
GetMetrics returns all metrics for all given queries. For each given query we have to make one call to the Prometheus API. Then we have to loop through the returned time series and transform them into a format, which can be processed by out React UI.
func (*Instance) GetTableData ¶
func (i *Instance) GetTableData(ctx context.Context, queries []Query, timeEnd int64) (map[string]map[string]string, error)
GetTableData returns the data, when the user selected the table view for the Prometheus plugin. To get the data we are running all prodived queries and join the results by the value for a label of a query. The value for a query is added as value-N column. We are also adding all other labels as fields to a single row.
func (*Instance) GetVariable ¶
func (i *Instance) GetVariable(ctx context.Context, label, query, queryType string, timeStart, timeEnd int64) ([]string, error)
GetVariable returns all values for a label from the given query. For that we have to retrive the label sets from the Prometheus instance and so that we can add the values for the specified label to the values slice.
type Metric ¶
type Metric struct { ID string `json:"id"` Label string `json:"label"` Min float64 `json:"min"` Max float64 `json:"max"` Avg float64 `json:"avg"` Data []Datum `json:"data"` }
Metric is the response format for a single metric. Each metric must have an ID and label. We also add the min, max and average for the returned data.
type Metrics ¶ added in v0.6.0
type Metrics struct { StartTime int64 `json:"startTime"` EndTime int64 `json:"endTime"` Min float64 `json:"min"` Max float64 `json:"max"` Metrics []Metric `json:"metrics"` }
Metrics is the structure for the returned metrics from the Prometheus metrics API endpoint. It contains a list of metrics, the start and end time for the query and the min and max value accross all time series.