Understand time series

Understand time series

In section 1.2 which, by Node Exporter exposed HTTP services, Prometheus current sample data can be collected to host all monitoring indicators. E.g:

# HELP node_cpu Seconds the cpus spent in each mode.
# TYPE node_cpu counter
node_cpu{cpu="cpu0",mode="idle"} 362812.7890625
# HELP node_load1 1m load average.
# TYPE node_load1 gauge
node_load1 3.0703125

Wherein each row represents the beginning of the current non-# Node Exporter collected a surveillance sample: node_cpu and node_load1 indicate the name of the current indicators, braces label reflects some of the characteristics and dimensions of the current sample, the float is monitored specific values ​​of the samples.

sample

Prometheus will all samples collected in time series data (time-series) manner in memory in the database, and the timing saved to the hard disk. time-series order in accordance with the sequence stored timestamp value and we call vector (Vector). Each time-series by Index Name (metrics name) and a set of set of labels (labelset) named. As shown below, time-series may be understood as a time-digital matrix Y axis:

  ^
  │   . . . . . . . . . . . . . . . . .   . .   node_cpu{cpu="cpu0",mode="idle"}
  │     . . . . . . . . . . . . . . . . . . .   node_cpu{cpu="cpu0",mode="system"}
  │     . . . . . . . . . .   . . . . . . . .   node_load1{}
  │     . . . . . . . . . . . . . . . .   . .  
  v
    <------------------ time ---------------->

Each point in the time-series is called a sample (sample), the sample consists of the following three parts:

  • Indicator (metric): metric name and description of the current sample feature labelsets;
  • Timestamp (timestamp): a millisecond accurate time stamp;
  • Sample values ​​(value): folat64 a floating-point data represents the value of the current sample.
  • <--------------- metric ---------------------><-timestamp -><-value->
    http_request_total{status="200", method="GET"}@1434417560938 => 94355
    http_request_total{status="200", method="GET"}@1434417561287 => 94334
    http_request_total{status="404", method="GET"}@1434417560938 => 38473
    http_request_total{status="404", method="GET"}@1434417561287 => 38544
    http_request_total{status="200", method="POST"}@1434417560938 => 4748
    http_request_total{status="200", method="POST"}@1434417561287 => 4785

     

Indicator (Metric)

Formally, all the indicators (Metric) are indicated by the following format:

<metric name>{<label name>=<label value>, ...}

Name Index (metric name) can be monitored to reflect the meaning of a sample (for example, http_request_total - indicates that the current system, the total amount of the received HTTP request). Index names can only consist of ASCII characters, numbers, underscores and colons composition and must comply with regular expressions [a-zA-Z_:][a-zA-Z0-9_:]*.

Tag (label) which is characteristic of the current sample dimensions, Prometheus sample data may be filtered by these dimensions polymerization. Name tags can only consist of ASCII characters, numbers, and the underscore and the regular expression [a-zA-Z_][a-zA-Z0-9_]*.

Which __as a prefix tag is a keyword reserved for the system, it can only be used within the system. Value of the tag can contain any Unicode characters. Implementation indicators name at the bottom of Prometheus is actually a __name__=<metric name>form saved in the database, the following two methods are represented with a time-series:

api_http_requests_total{method="POST", handler="/messages"}

Equivalent to:

{__name__="api_http_requests_total",method="POST", handler="/messages"}

在Prometheus源码中也可以指标(Metric)对应的数据结构,如下所示:

type Metric LabelSet
type LabelSet map[LabelName]LabelValue
type LabelName string
type LabelValue string

 

Guess you like

Origin www.cnblogs.com/twobrother/p/11933392.html