Telegraf: backslash in object name of config file for windows perf counters SQL instance metrics

Created on 6 May 2016  路  17Comments  路  Source: influxdata/telegraf

I'm trying to enter "\hostname\MSSQL$Sqlinstance:General Statistics" in the objectname field.

When trying to start telegraf, the config file cannot be parsed.

need more info

Most helpful comment

no, just define the plugin in your config file and it will get run:

# Read metrics from Microsoft SQL Server
[[inputs.sqlserver]]
  # Specify instances to monitor with a list of connection strings.
  # All connection parameters are optional. 
  # By default, the host is localhost, listening on default port (TCP/1433) 
  #    for Windows, the user is the currently running AD user (SSO).
  #    See https://github.com/denisenkom/go-mssqldb for detailed connection parameters.

  servers = [
    "Server=192.168.1.30;Port=1433;User Id=telegraf;Password=T$l$gr@f69*;app name=telegraf;log=1;",
    "Server=192.168.1.30;Port=2222;User Id=telegraf;Password=T$l$gr@f69*;app name=telegraf;log=1;"
    ]

All 17 comments

need more info:

  1. config file
  2. error message
  3. version

Error is "Error Parsing .\telegraf.conf, toml: Line 135 parse error.

Section of config file is:
[[inputs.win_perf_counter.object]]
ObjectName = "\localhost\mssql$mysqlinstance:General Statistics"
Counters = ["User Connections"]

Line 135 is the ObjectName one

This is running telegraf on windows V0.12.1

If i use
ObjectName = "\\localhost\mssql$mysqlinstance:General Statistics"

the config file parses but i dont get any metrics, probably because it thinks that object name is then not formatted correctly trying to actually get the win perf counter

what is the actual object name you're trying to get?

When you use an Instance name in SQL rather than the default "Instance" during install you need to specify it in the counter request.
The object is called "\LOCALHOST\MSSQL$SQLINSTANCENAME:General Statistics
or
\LOCALHOST\MSSQL$SQLINSTANCENAME:Memory Buffer
These work in powershell, but i cant specify them in the telegraf config.

The other counters are working fine "CPU" and "Memory" etc but because these counters need the full name the backslash seems to cause a problem

Get-counter -Counter "\Servername\MSSQL$SQLInstancename:General Statistics\User connections" returns a value as expected from within powershell

thankyou for your help looking into this :)

i suppose the other option is to use the SQLServer plugin to read directly off the SQL server

https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sqlserver

but i'm not 100% sure how to actually use the files displayed in that link to setup the telegraf.exe and telegraf.conf (the only 2 files in windows) and get it working.

I'm new to telegraf and github, so i may be asking silly questions.

doesn't the case matter? why not keep the case consistent in your telegraf config file?

I'm not really sure you need any backslashing at all, as those might be escape characters in powershell.

I've tried with different cases. I've tried with multiple quote marks and single quotes inside the double quotes, none of them work.

For those particular counters you need to have backslashes unfortunately.

OK well if its a non starter as a \ is an escape character in telegraf then i'll need to sort out the sqlserver input plugin.

Can that be installed directly on a Windows machine or will i need a linux machine running telegraf with those input files on it to pull the data from sql ?

no, just define the plugin in your config file and it will get run:

# Read metrics from Microsoft SQL Server
[[inputs.sqlserver]]
  # Specify instances to monitor with a list of connection strings.
  # All connection parameters are optional. 
  # By default, the host is localhost, listening on default port (TCP/1433) 
  #    for Windows, the user is the currently running AD user (SSO).
  #    See https://github.com/denisenkom/go-mssqldb for detailed connection parameters.

  servers = [
    "Server=192.168.1.30;Port=1433;User Id=telegraf;Password=T$l$gr@f69*;app name=telegraf;log=1;",
    "Server=192.168.1.30;Port=2222;User Id=telegraf;Password=T$l$gr@f69*;app name=telegraf;log=1;"
    ]

so just copy the sqlserver.go file into the same directory as the telegraf.exe and the telegraph.conf and then specify as above in the the conf file ?

no, you already have the plugin in telegraf.exe, just define the above config in telegraf.conf, you do not need any .go files, this is not a scripting language ;-)

oh - perfect !

Thanks for your help - i'll try it now.

all working !

thankyou

closing because this is available in the sqlserver plugin

I have a similar problem:
I just setup my telegraf.conf who run a powershell script with a path as an argument.
Problem is : My argument can be a network path, and it seems like there are no way to use backslash in the exec string.
commands = ['powershell ./parse_send_csv.ps1 "\blabla\a"']

Using \\ results to having 2 backslash : Not working
Using only one \ results to no backslash : Not working
Using single or double quote : Not working
I even tried to escape with ` character (escaping character in golang) with no success.
Anyone having same problem ?

Was this page helpful?
0 / 5 - 0 ratings