The explanation for all the lines in the Kafka Mapper is covered in the previous example section. This example provides more information on the metrics label name.
Input | Kafka Mapper | Output |
---|---|---|
{ "labels":{ "RSRPDISTRANGESRC":"0", "mtcilId":"mtcil1", "DUID":"851016010", "RSRPDISTRANGETGT":"0", "app":"ueconmgr", "msuid":"bb72d40a-9945-45fd-a7ec-aadf8fe15690-001", "kubernetes_pod_name":"ueconmgr-c59c95db8-924hm", "NRCGI":"86465872771973326", "nfType":"cucp", "haRole":"active", "kubernetes_namespace":"lasnv001b-ns-mv-cucp-851016", "mtcil_com_mmaas_clock_aligned":"true", "instance":"100.125.255.61:6060", "RUID":"851017223", "nfId":"cucp-851016000", "timestamp":1636651944000, "GroupName":"HORSRPDISTRIBUTION", "job":"kubernetes-pods", "CellClusterId":"111", "__name__":"HoRsrpDist_UENbrRsrpDist", "nfinstanceid":"ueconmgr1", "CUCPID":"851016000", "TGTNRCGI":"86465872771973315", "pod_template_hash":"c59c95db8", "microSvcName":"ueconmgr", "svc":"ueconmgrappln", "value":1.0, "token":"001", "source_port":"8081" } } |
Kafka Mapper { "metricType":"vran", "instance":"mavenir-metrics", "properties.entityName":"$.labels.app", "properties.entityType":"app", "processedTimestamp":"$.labels.timestamp", "type":"KafkaCollector", "properties.dataSource":"$.labels.instance", "properties.deviceName":"$.labels.kubernetes_pod_name", "metrics.$['labels']['__name__']":"$.labels.value", "timestamp":"$.labels.timestamp", "properties.deviceType":"$.labels.app", "tags":"$.labels" } |
{ "instance":"mavenir-metrics", "metricType":"vran", "timestamp":1636651944000, "processedTimestamp":1645371912210, "type":"KafkaCollector", "metrics":{ "HoRsrpDist_UENbrRsrpDist":1.0 }, "properties":{ "deviceType":"ueconmgr", "entityName":"ueconmgr", "entityType":"app", "dataSource":"100.125.255.61:6060", "deviceName":"ueconmgr-c59c95db8-924hm" }, "tags":{ "nfId":"cucp-851016000", "GroupName":"HORSRPDISTRIBUTION", "instance":"100.125.255.61:6060", "TGTNRCGI":"86465872771973315", "DUID":"851016010", "RSRPDISTRANGESRC":"0", "NRCGI":"86465872771973326", "nfinstanceid":"ueconmgr1", "kubernetes_namespace":"lasnv001b-ns-mv-cucp-851016", "RSRPDISTRANGETGT":"0", "source_port":"8081", "CUCPID":"851016000", "CellClusterId":"111", "msuid":"bb72d40a-9945-45fd-a7ec-aadf8fe15690-001", "value":"1.0", "timestamp":"1636651944000", "app":"ueconmgr", "svc":"ueconmgrappln", "mtcilId":"mtcil1", "nfType":"cucp", "pod_template_hash":"c59c95db8", "microSvcName":"ueconmgr", "kubernetes_pod_name":"ueconmgr-c59c95db8-924hm", "mtcil_com_mmaas_clock_aligned":"true", "token":"001", "__name__":"HoRsrpDist_UENbrRsrpDist", "RUID":"851017223", "haRole":"active", "job":"kubernetes-pods" } } |
metrics.$['labels']['__name__']":"$.labels.value: In last example, the entire metrics and the tags node are assigned to JSONPath expression returning a JSON Node. The metrics.$['labels']['__name__']":"$.labels.value brings out another method of adding key value pairs to the metrics node in the VMware Telco Cloud Service Assurance Metric.
As stated in line 3 of last example - Any key containing a '.' (dot) and left part of the string matching the string
metrics,
properties, or
tags are broken down. The right part of the string are treated as the attribute name, within the node identified by the left part of the string. Here the attribute name is a JSON Path expression -
$['labels']['__name__']
.
Note: The . (dot) notation is not supported in keys, therefore, bracket notation is used here. The above expression resolves to
__name__ attribute inside the labels node and the value for the same as per the input is
HoRsrpDist_UENbrRsrpDist. This forms the Key within the metrics node in the output
VMware Telco Cloud Service Assurance Metric. The value are derived by another JSONPath expression
$.labels.value
. This resolves to the
value attribute inside the labels node and the value for the same as per the input is
1.0.
Therefore, for the input line:
{ "metrics.$['labels']['__name__']":"$.labels.value" } would resolve to the output { "metrics":{ "HoRsrpDist_UENbrRsrpDist":1.0 } }