Hello
I’m gathering SQL server related metrics (but that’s not important, the problem can be applied to any input) using Telegraf, and I’ve been asked to set up a filter on a subset of points.
The input configuration runs different queries and writes several measurements, I have to filter only one measurement and keep only certain values (based on a tag value)
To do so, I should apply in cascade namepass and tagpass which is not possible since them both work on the whole input.
to put it as a list:
- fetch the data
- apply a filter on a specific measurement
2.1 on this measurement, filter a specific tag value - do all this in a single input plugin
Example
Let’s say that I want to:
apply a filter on the sqlserver_requests measurements and keep only the “AdventureWorks2016” (database_name) related points
Sample input
sqlserver_requests,database_name=AdventureWorks2016,sql_instance=QDLP03:SQL2017,query_hash=aaa Somefield=10
sqlserver_requests,database_name=AdventureWorks2016,sql_instance=QDLP03:SQL2017,query_hash=bbb Somefield=2
sqlserver_requests,database_name=Northwind,sql_instance=QDLP03:SQL2017,query_hash=ccc Somefield=4
sqlserver_requests,database_name=Northwind,sql_instance=QDLP03:SQL2017,query_hash=ddd Somefield=6
sqlserver_cpu,sql_instance=QDLP03:SQL2017 other_process_cpu=8i,sqlserver_process_cpu=12i,system_idle_cpu=80i
Desired Output
sqlserver_requests,database_name=AdventureWorks2016,sql_instance=QDLP03:SQL2017,query_hash=aaa Somefield=10
sqlserver_requests,database_name=AdventureWorks2016,sql_instance=QDLP03:SQL2017,query_hash=bbb Somefield=2
sqlserver_cpu,sql_instance=QDLP03:SQL2017 other_process_cpu=8i,sqlserver_process_cpu=12i,system_idle_cpu=80i
note that only a subset of points from the sqlserver_requests measurements has been filterd
Is it possible to do this by combining namepass and tagpass without splitting the input configuration?
current “solution”
As of now, the only solution I have is to create 2 separated input configuration, one with all the metric except the one that I want to filter and another one in which namepass and *tagpass are applied (or… since it just fetch one measurement, just tagpass is enough)
## fetch all the metrics that do NOT need filtering
[[[inputs.sqlserver]]
{...plugin config...}
## do NOT include "SqlRequests"
include_query = ['VolumeSpace','QueryStats','Cpu']
[[[inputs.sqlserver]]
{...plugin config...}
##include only queries to be filterd
include_query = ['SqlRequests']
## Filter measurement name
namepass = ['sqlserver_requests']
##apply additional filter on tag
[inputs.sqlserver.tagpass]
database_name = ['AdventureWorks2016']
Question
- Is it possible to obtain the same result without splitting the input configuration in two?
- Can namepass and tagpass be combined to filter only a subset of points?