Documentation
¶
Index ¶
- func Register(cfg []Config, grpcServer *grpc.Server) ([]*pluginsProto.PluginShort, error)
- type Config
- type Instance
- type Prometheus
- func (p *Prometheus) GetMetrics(ctx context.Context, getMetricsRequest *prometheusProto.GetMetricsRequest) (*prometheusProto.GetMetricsResponse, error)
- func (p *Prometheus) GetTableData(ctx context.Context, getTableDataRequest *prometheusProto.GetTableDataRequest) (*prometheusProto.GetTableDataResponse, error)
- func (p *Prometheus) GetVariables(ctx context.Context, getVariablesRequest *prometheusProto.GetVariablesRequest) (*prometheusProto.GetVariablesResponse, error)
- func (p *Prometheus) MetricLookup(ctx context.Context, metricsLookupRequest *prometheusProto.MetricLookupRequest) (*prometheusProto.MetricLookupResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(cfg []Config, grpcServer *grpc.Server) ([]*pluginsProto.PluginShort, error)
Types ¶
type Prometheus ¶
type Prometheus struct {
prometheusProto.UnimplementedPrometheusServer
// contains filtered or unexported fields
}
func (*Prometheus) GetMetrics ¶
func (p *Prometheus) GetMetrics(ctx context.Context, getMetricsRequest *prometheusProto.GetMetricsRequest) (*prometheusProto.GetMetricsResponse, error)
GetMetrics returns all metrics for all given queries. For that we are creating a map of with the selected values for all variables. Then we are looping through the list of variables, replacing the variables with the selected value and run the PromQL against the configured Prometheus instance. In the last step we transform the result, so that it can be used in the React UI.
func (*Prometheus) GetTableData ¶ added in v0.3.0
func (p *Prometheus) GetTableData(ctx context.Context, getTableDataRequest *prometheusProto.GetTableDataRequest) (*prometheusProto.GetTableDataResponse, error)
GetTableData implements the GetTableData function from the Prometheus gRPC service. It takes a list of queries and returns the corresponding data in a table format. In the first step we parse the result of each query into a map[string]map[string]string, where the key of the first map is the provided label for a query. This means the label of each querie should result in the same value, so that we can join the results of the different queries. The second map holds all labels and label values. The value of the query result is also added to this map with a key named "value-N". Finally we transform the map[string]map[string]string is converted to the map[string]*prometheusProto.Row structure, which can be used in the response.
func (*Prometheus) GetVariables ¶
func (p *Prometheus) GetVariables(ctx context.Context, getVariablesRequest *prometheusProto.GetVariablesRequest) (*prometheusProto.GetVariablesResponse, error)
GetVariables returns all variable values. The values are label values for a Prometheus time series. The labels are retrieved via a PromQL query. To get the values we are looping over all queries and pre selecting the first value or all values, when the option is set. So we can use a variable in a following query.
func (*Prometheus) MetricLookup ¶ added in v0.2.0
func (p *Prometheus) MetricLookup(ctx context.Context, metricsLookupRequest *prometheusProto.MetricLookupRequest) (*prometheusProto.MetricLookupResponse, error)
MetricLookup 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.