backend-meter.md 3.8 KB
Newer Older
W
Wing 已提交
1 2
# Meter receiver
The meter receiver accepts the metrics of [meter protocol](https://github.com/apache/skywalking-data-collect-protocol/blob/master/language-agent/Meter.proto) into the [meter system](./../../concepts-and-designs/meter.md).
3

W
Wing 已提交
4
## Module definition
5
Module definition is defined in `application.yml`, typically located at `$SKYWALKING_BASE_DIR/config/application.yml` by default.
6
```yaml
7 8 9 10
receiver-meter:
  selector: ${SW_RECEIVER_METER:default}
  default:

11 12
```

W
Wing 已提交
13
In Kafka Fetcher, follow these configurations to enable it.  
14 15 16 17 18 19 20
```yaml
kafka-fetcher:
  selector: ${SW_KAFKA_FETCHER:default}
  default:
    bootstrapServers: ${SW_KAFKA_FETCHER_SERVERS:localhost:9092}
```

21 22
## Meter collection

23
Custom metrics may be collected by Manual Meter API.
24 25
Custom metrics collected cannot be used directly, they should be configured in `meter-analyzer-config` configuration files, which is described in next part.

26 27 28 29 30 31
The receiver adds labels with `key = service` and `key = instance` to the collected data samples,
and values from service and service instance name defined in SkyWalking Agent,
for identification of the metric data.

A typical manual meter API set is [Spring Sleuth APIs](spring-sleuth-setup.md)

32
## Configuration file
W
Wing 已提交
33
The meter receiver is configured via a configuration file. The configuration file defines everything related to receiving 
34 35
 from agents, as well as which rule files to load.
 
W
Wing 已提交
36
The OAP can load the configuration at bootstrap. If the new configuration is not well-formed, the OAP may fail to start up. The files
37
are located at `$CLASSPATH/meter-analyzer-config`.
38

39 40 41 42 43 44 45 46 47 48
New meter-analyzer-config files is **NOT** enabled by default, you should make meter configuration take effect through section `agent-analyzer` in `application.yml` of skywalking backend.
```yaml
 agent-analyzer:
   selector: ${SW_AGENT_ANALYZER:default}
   default:
     # ... take care of other analyzers
     meterAnalyzerActiveFiles: ${SW_METER_ANALYZER_ACTIVE_FILES:your-custom-meter-conf-without-ext-name} # The multiple files should be separated by ","
```

Meter-analyzer-config file is written in YAML format, defined by the scheme described below. Brackets indicate that a parameter is optional.
49

50
An example can be found [here](../../../../oap-server/server-starter/src/main/resources/meter-analyzer-config/spring-sleuth.yaml).
W
Wing 已提交
51
If you're using Spring Sleuth, see [Spring Sleuth Setup](spring-sleuth-setup.md).
52

53 54 55 56
| Rule Name | Description | Configuration File | Data Source |
|-----|-----|-----|-----|
|spring-sleuth| Metrics of Spring Sleuth Application | meter-analyzer-config/spring-sleuth.yaml | Sprign Sleuth Application --meter format--> SkyWalking OAP Server |

W
Wing 已提交
57
### Meters configuration
58 59

```yaml
60 61
# filter the metrics, only those metrics that satisfy this condition will be passed into the `metricsRules` below.
filter: <closure> # example: '{ tags -> tags.job_name == "vm-monitoring" }'
62 63 64 65 66 67
# expSuffix is appended to all expression in this file.
expSuffix: <string>
# insert metricPrefix into metric name:  <metricPrefix>_<raw_metric_name>
metricPrefix: <string>
# Metrics rule allow you to recompute queries.
metricsRules:
68 69
  # The name of rule, which combinates with a prefix '<metricPrefix>_' as the index/table name in storage.
  # The name with prefix can also be quoted in UI (Dashboard/Template/Item/Metrics)
70
  name: <string>
71
  # MAL expression. Raw name of custom metrics collected can be used here
72
  exp: <string>
73 74
```

W
Wing 已提交
75
For more information on MAL, please refer to [mal.md](../../concepts-and-designs/mal.md)
76

W
Wing 已提交
77
#### `rate`, `irate`, and `increase`
78

W
Wing 已提交
79 80 81
Although we support the `rate`, `irate`, `increase` functions in the backend, we still recommend users to consider using client-side APIs to run these functions. The reasons are as follows:
1. The OAP has to set up caches to calculate the values.
1. Once the agent reconnects to another OAP instance, the time windows of rate calculation break. This leads to inaccurate results.