--- sort: 34 weight: 34 title: Key concepts menu: docs: parent: 'victoriametrics' weight: 34 aliases: - /keyConcepts.html - /keyсoncepts.html --- # Key concepts ## Data model ### What is a metric Simply put, `metric` is a numeric measure or observation of something. The most common use-cases for metrics are: - check how the system behaves at the particular time period; - correlate behavior changes to other measurements; - observe or forecast trends; - trigger events (alerts) if the metric exceeds a threshold. ### Structure of a metric Let's start with an example. To track how many requests our application serves, we'll define a metric with the name `requests_total`. You can be more specific here by saying `requests_success_total` (for only successful requests) or `request_errors_total` (for requests which failed). Choosing a metric name is very important and supposed to clarify what is actually measured to every person who reads it, just like **variable names** in programming. #### Labels Every metric can contain additional meta-information in the form of label-value pairs: ``` requests_total{path="/", code="200"} requests_total{path="/", code="403"} ``` The meta-information - a set of `labels` in curly braces - gives us a context for which `path` and with what `code` the `request` was served. Label-value pairs are always of a `string` type. VictoriaMetrics data model is schemaless, which means there is no need to define metric names or their labels in advance. User is free to add or change ingested metrics anytime. Actually, the metric name is also a label with a special name `__name__`. So the following two series are identical: ``` requests_total{path="/", code="200"} {__name__="requests_total", path="/", code="200"} ``` Labels can be automatically attached to the [time series](#time-series) written via [vmagent](https://docs.victoriametrics.com/vmagent/#adding-labels-to-metrics) or [Prometheus](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prometheus-setup). VictoriaMetrics supports enforcing of label filters for [query API](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prometheus-querying-api-enhancements) to emulate data isolation. However, the real data isolation can be achieved via [multi-tenancy](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multitenancy). #### Time series A combination of a metric name and its labels defines a `time series`. For example, `requests_total{path="/", code="200"}` and `requests_total{path="/", code="403"}` are two different time series because they have different values for `code` label. The number of unique time series has an impact on database resource usage. See [what is an active time series](https://docs.victoriametrics.com/faq/#what-is-an-active-time-series) and [what is high churn rate](https://docs.victoriametrics.com/faq/#what-is-high-churn-rate) docs for details. #### Cardinality The number of unique [time series](#time-series) is named `cardinality`. Too big number of unique time series is named `high cardinality`. High cardinality may result in increased resource usage at VictoriaMetrics. See [these docs](https://docs.victoriametrics.com/faq/#what-is-high-cardinality) for more details. #### Raw samples Every unique time series may consist of an arbitrary number of `(value, timestamp)` data points (aka `raw samples`) sorted by `timestamp`. VictoriaMetrics stores all the `values` as [float64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) with [extra compression](https://faun.pub/victoriametrics-achieving-better-compression-for-time-series-data-than-gorilla-317bc1f95932) applied. This allows storing precise integer values with up to 12 decimal digits and any floating-point values with up to 12 significant decimal digits. If the value has more than 12 significant decimal digits, then the less significant digits can be lost when storing them in VictoriaMetrics. The `timestamp` is a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) with millisecond precision. Below is an example of a single raw sample in [Prometheus text exposition format](https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#text-based-format): ``` requests_total{path="/", code="200"} 123 4567890 ``` - The `requests_total{path="/", code="200"}` identifies the associated time series for the given sample. - The `123` is a sample value. - The `4567890` is an optional timestamp for the sample. If it is missing, then the current timestamp is used when storing the sample in VictoriaMetrics. #### Time series resolution Resolution is the minimum interval between [raw samples](https://docs.victoriametrics.com/keyconcepts/#raw-samples) of the [time series](https://docs.victoriametrics.com/keyconcepts/#time-series). Consider the following example: ``` ---------------------------------------------------------------------- |