Write code to Telegraf

How can i write code to telegraf to fetch a particular metrics from SQL server.?
From my understanding Telegraf collects a lot of metrics from SQL server if i am using Telegraf SQL server plugin.
How can i write code to telegraf to get a particular metric?

I googled a bit and found these:

and noticed that you got a similar answer here (adding this so that others find it).

Unfortunately the sqlserver plugin only provides information about the sql server metric itself. However, I’ve written on that can query sqlserver’s but it’s not supported, or merged back into the main telegraf yet either. I’ve been using it to consolidate a number of different metrics into our influx database and it’s worked quite well. I’d be happy to send more information about it if that helps.


My time is a little limited, so I can’t promise I’ll be very timely, but I will help if I can.