Value mapping with derived labels
There are these types of derived labels:
- A mapping derived label creates a new label name and pulls values from some other label on the time series. Value mapping applies to mapping derived labels.
- A constructed derived label creates a label name and values where one didn't previously exist. By definition, Chronosphere already creates values for a constructed derived label, so value mapping doesn't apply to constructed derived labels.
The following examples start with this set of time series:
{__name__="grpc_metric", service="labrador", instance="blah"}
{__name__="grpc_metric", service="golden", instance="blah"}
{__name__="envoy_metric", microservice="Labrador", instance="blah"}
{__name__="envoy_metric", microservice="GOLDEN", instance="blah"}
Standardize label names
Different teams or services provide source data, some of which might not conform to the intended labeling standard. For cleaner reviews, you can map all of the provided into a standardized space. Nothing can be added to the target space without explicit mapping, which preserves and augments the original labeling.
For example:
Source | Target |
---|---|
TS1, service=labrador | TS1, service=labrador , standard-service=labrador-retriever |
TS2, service=golden | TS2, service=golden , standard-service=golden-retriever |
TS3, microservice=Labrador | TS3, microservice=Labrador , standard-service=labrador-retriever |
Top-level value mappings
Top-level value mappings are mappings that apply to all name mappings, and not to a
specific name mapping. This MappingLabel includes top-level value mappings in the value_mappings
section.
label_name: standard_service
mapping_label:
name_mappings:
- filters:
- name: __name__
value_glob: grpc_*
source_label: service
- filters:
- name: __name__
value_glob: envoy_*
source_label: microservice
value_mappings:
- source_value_globs:
- labrador
- Labrador
target_value: labrador-retriever
- source_value_globs:
- golden
- GOLDEN
target_value: golden-retriever
If you were to use the query grpc_metric{standard_service="labrador-retriever"}
,
the resulting time series is:
{__name__="grpc_metric", service="labrador", standard_service="labrador-retriever", instance="blah"}
For another query envoy_metric{standard_service="labrador-retriever"}
, the
resultingtime series is:
{__name__="envoy_metric", microservice="Labrador", standard_service="labrador-retriever", instance="blah"}
If you query using an non-existent target value such as
grpc_metric{standard_service="labrador"}
, it returns this time series:
{__name__="grpc_metric", service="labrador", standard_service="labrador-retriever", instance="blah"}
Value mappings inside a name mapping
Value mappings match to one specific name mapping.
For example:
label_name: standard_service
mapping_label:
name_mappings:
- filters:
- name: __name__
value_glob: grpc_*
source_label: service
value_mappings:
- source_value_globs:
- labrador
- Labrador
target_value: labrador-retriever
- filters:
- name: __name__
value_glob: envoy_*
source_label: microservice
If we query grpc_metric{standard_service="labrador-retriever"}
, with this configuration, the target value labrador-retriever
applies only to
metrics that match __name__:grpc_*
.
The resulting time series is:
{__name__="grpc_metric", service="labrador", standard_service="labrador-retriever", instance="blah"}
Consider the query envoy_metric{standard_service="labrador-retriever"}
. According
to the configuration, the value mapping for labrador-retriever
applies only to
metrics that match __name__:grpc_*
.
This query returns no results because:
standard_service="labrador-retriever"
isn't a physical label-value pair onenvoy_metric
.- There is no top-level value mapping where
labrador-retriever
is the target value. There's also no name mapping specific value mapping wherelabrador-retriever
is the target value for metrics that match__name__:envoy_*
.
Use value mapping inside name mapping with top level mapping together
You can use Value Mappings and name mapping level value mappings in the same configuration. For example:
label_name: standard_service
mapping_label:
name_mappings:
- filters:
- name: __name__
value_glob: grpc_*
source_label: service
value_mappings:
- source_value_glob:
- labrador
- Labrador
target_value: labrador-retriever
- filters:
- name: __name__
value_glob: envoy_*
source_label: microservice
value_mappings:
- source_value_globs:
- labrador
- Labrador
target_value: golden-retriever
In this example, target value labrador-retriever
applies specifically to metrics
that matches __name__:grpc_*
because it matches to that specific name mapping,
where value labrador-retriever
applies to all name mappings.
For the query grpc_metric{standard_service="labrador-retriever"}
results in the time
series:
{__name__="grpc_service", service="labrador", standard_service="labrador-retriever", instance="blah"}
Similarly, for the query envoy_metric{standard_service="golden-retriever"}
, the
resulting time series is:
{__name__="envoy_metric", microservice="GOLDEN", standard_service="golden-retriever", instance="blah"}
However, querying envoy_metric{standard_service="labrador-retriever"}
returns no
values, because:
standard_service="labrador-retriever"
isn't a physical label-value pair onenvoy_metric
.- There is no top-level value mapping where
labrador-retriever
is the target value. There's also no name mapping that has a value mapping wherelabrador-retriever
is the target value for metrics that match__name__:envoy_*
.
If there is a top-level value mapping with the same target value as a name mapping specific value mapping, like this situation:
label_name: standard_service
mapping_label:
name_mappings:
- filters:
- name: __name__
value_glob: grpc_*
source_label: service
value_mappings:
- source_value_filters:
- labrador
- Labrador
target_value: golden-retriever
- filters:
- name: __name__
value_glob: envoy_*
source_label: microservice
value_mappings:
- source_value_globs:
- golden
- GOLDEN
target_value: golden-retriever
In this case, both value mappings have the same target value of golden-retriever
.
The value mappings that are name mapping specific apply over the top-level value
mappings.