App Metrics allows you to filter Metrics per reporter.
Below is an example reporting configuration which provides a filter to a console reporter filtering Metrics containing a tag key of "filter-tag1" and are Counters
[!code-csharpMain]
Metrics can also be set at a global level which would apply to all Metric data queries.
Below is an example of how to apply a global filter in a Web Host.
[!code-csharpMain]
Requesting the /metrics
endpoint with the above configuration would result in only Counter Metrics being shown in the response.
In cases where a global filter is set as well as a filter on a reporter, the reporter's filter will be used instead.
It is also possible to override the global filter if you where to retrieve a snapshot of the current metrics data via the Advanced Metric contract.
[!code-csharpMain]
Metrics can be filtered by:
- Metric Type
- Tags
- Context
- Metric Name (Exact match or where name starts with)
Tip
Custom Metric Filters can be implemented rather than using the DefaultMetricsFilter by implementing IMetricsFilter.