Documentation ¶
Index ¶
- Constants
- Variables
- func ExpressFromMetricsMap(name, label string) (string, error)
- func Parse2pbQueryRangeResp(value model.Value, metricFilter func(metric model.Metric) bool) *pb.MetricsData
- func Parse2pbQueryResp(value model.Value, metricFilter func(metric model.Metric) bool) *pb.MetricsData
- type CSVPoint
- type DashboardEntity
- type ExportPoint
- type Metric
- type MetricData
- type MetricMetadata
- type MetricValue
- type MetricValues
- type Point
Constants ¶
View Source
const ( MetricTypeMatrix = "matrix" MetricTypeVector = "vector" )
Variables ¶
View Source
var MetricsMap = map[string]string{
"sum_tkapi_request_7d": "ceil(sum(increase(tkapi_request_total{$}[7d])))",
"sum_tkapi_request_24h": "ceil(sum(increase(tkapi_request_total{$}[24h])))",
"avg_tkapi_request_latency_7d": "sum(increase(tkapi_request_duration_seconds_sum{$}[7d])) /sum(increase(tkapi_request_duration_seconds_count{$}[7d]))",
"avg_tkapi_request_latency_24h": "sum(increase(tkapi_request_duration_seconds_sum{$}[24h])) /sum(increase(tkapi_request_duration_seconds_count{$}[24h]))",
"sum_tkapi_request_1h": "ceil(sum(increase(tkapi_request_total{$}[1h])))",
"num_tkapi_request": "sum((tkapi_request_total{$}))",
"p999_tkapi_request_latency": "histogram_quantile(0.999, sum by (le) (rate(tkapi_request_duration_seconds_bucket{$}[1h])))",
"p95_tkapi_request_latency": "histogram_quantile(0.95, sum by (le) (rate(tkapi_request_duration_seconds_bucket{$}[1h])))",
"p99_tkapi_request_latency": "histogram_quantile(0.99, sum by (le) (rate(tkapi_request_duration_seconds_bucket{$}[1h])))",
"upstream_msg": "sum(iothub_msg_total{direction='upstream',$})",
"upstream_msg_24h": "ceil(sum(increase(iothub_msg_total{direction='upstream',$}[24h])))",
"downstream_msg": "sum(iothub_msg_total{direction='downstream',$})",
"downstream_msg_24h": "ceil(sum(increase(iothub_msg_total{direction='downstream',$}[24h])))",
"subscribe_num": "(sum(subscribe_num{$})) / (count (sum by (pod) (subscribe_num)))",
"subscribe_entities_num": "sum(subscribe_entities_num{$}) / (count (sum by (pod) (subscribe_entities_num)))",
"rule_num": "sum(rule_num{$}) / (count (sum by (pod) (rule_num)))",
"rule_execute_num_24h": "sum(increase(rule_execute_num{$}[24h]))",
"rate_rule_failure_24h": "ceil((sum(rule_execute_num{status='failure',$}) / sum(rule_execute_num{$}))*100)",
"num_rule_execute_failure": "sum(rule_execute_num{status='failure',$})",
"num_rule_execute_success": "sum(rule_execute_num{status='success',$})",
"rate_rule_execute_failure_5m": "sum(rate(rule_execute_num{status='failure',$}[5m]))",
"rate_rule_execute_success_5m": "sum(rate(rule_execute_num{status='success',$}[5m]))",
"sum_device_num": "sum(device_num_total{$}) / (count (sum by (pod) (device_num_total)))",
"sum_template_num": "sum(device_template_total{$}) / (count (sum by (pod) (device_template_total)))",
"rate_online": "ceil((sum(device_online_total{$}) / sum(device_num_total{$})) * 100)",
"msg_storage_days": "((sum(msg_storage_seconds{tenant_id='admin'})) / (count (sum by (pod) (msg_storage_seconds)))) / 86400",
"msg_storage_space_unused_bytes": "(sum(msg_storage_space{space_type='total'})-sum( msg_storage_space{space_type='used'} ))/(count (sum by (pod) (msg_storage_space)))",
"msg_storage_space_usage_percentage": "ceil((sum(msg_storage_space{space_type='used'}) / sum(msg_storage_space{space_type='total'}))*100)",
"core_msg_days": "ceil(sum(increase(core_msg_total{$}[1d])))",
"sum_iothub_connected": "sum(iothub_device_status{$})",
"sum_device_offline": "(sum(device_num_total{$}) / (count (sum by (pod) (device_num_total)))) - (sum(device_online_total{$})/ count (sum by (pod) (device_online_total)))",
"sum_device_online": "(sum(device_online_total{$})/ count (sum by (pod) (device_online_total)))",
}
Functions ¶
func ExpressFromMetricsMap ¶
func Parse2pbQueryRangeResp ¶
func Parse2pbQueryResp ¶
Types ¶
type DashboardEntity ¶
type ExportPoint ¶
type ExportPoint [2]float64
func (ExportPoint) Format ¶
func (p ExportPoint) Format() string
func (ExportPoint) Timestamp ¶
func (p ExportPoint) Timestamp() string
func (ExportPoint) TransformToCSVPoint ¶
func (p ExportPoint) TransformToCSVPoint(metricName string, selector string, resourceUnit string) CSVPoint
func (ExportPoint) Value ¶
func (p ExportPoint) Value() float64
type Metric ¶
type Metric struct { MetricName string `json:"metric_name,omitempty" description:"metric name, eg. scheduler_up_sum" csv:"metric_name"` MetricData `json:"data,omitempty" description:"actual metric result"` Error string `json:"error,omitempty" csv:"-"` }
type MetricData ¶
type MetricData struct { MetricType string `json:"result_type,omitempty" description:"result type, one of matrix, vector" csv:"metric_type"` MetricValues `json:"result,omitempty" description:"metric data including labels, time series and values" csv:"metric_values"` }
func ParseQueryRangeResp ¶
func ParseQueryResp ¶
type MetricMetadata ¶
type MetricValue ¶
type MetricValue struct { Metadata map[string]string `json:"metric,omitempty" description:"time series labels"` // The type of Point is a float64 array with fixed length of 2. // So Point will always be initialized as [0, 0], rather than nil. // To allow empty Sample, we should declare Sample to type *Point Sample *Point `json:"value,omitempty" description:"time series, values of vector type"` Series []Point `json:"values,omitempty" description:"time series, values of matrix type"` ExportSample *ExportPoint `json:"exported_value,omitempty" description:"exported time series, values of vector type"` ExportedSeries []ExportPoint `json:"exported_values,omitempty" description:"exported time series, values of matrix type"` MinValue string `json:"min_value" description:"minimum value from monitor points"` MaxValue string `json:"max_value" description:"maximum value from monitor points"` AvgValue string `json:"avg_value" description:"average value from monitor points"` SumValue string `json:"sum_value" description:"sum value from monitor points"` Fee string `json:"fee" description:"resource fee"` ResourceUnit string `json:"resource_unit"` CurrencyUnit string `json:"currency_unit"` }
func (*MetricValue) TransferToExportedMetricValue ¶
func (mv *MetricValue) TransferToExportedMetricValue()
type MetricValues ¶
type MetricValues []MetricValue
type Point ¶
type Point [2]float64
The first element is the timestamp, the second is the metric value. eg, [1585658599.195, 0.528]
func (Point) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will be called when writing JSON to HTTP response Inspired by prometheus/client_golang
func (*Point) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. This is for unmarshaling test data.
Click to show internal directories.
Click to hide internal directories.