sql_exporter icon indicating copy to clipboard operation
sql_exporter copied to clipboard

Query output value mapping

Open rahman13dec4u opened this issue 6 years ago • 1 comments

I'm using your sql_exporter...its great!!!However i'm having hard time mapping the query output back to prometheus..Can you please share a document if you have any..for example..i want to check disabled user my query is like :

 - metric_name: mssql_account_locked
    type: counter
#    type: gauge
    help: 'Account locked status'
    key_labels:
      - username
    value_label: status
    values: [cntr_value]
    query_ref: account_locked_out


- query_name: account_locked_out
    query: |
      SELECT
        name as username, is_disabled as cntr_value
      FROM sys.sql_logins

I should see in prometheus a metrics with name "mssql_account_locked" ..right ?

However i can't see it

rahman13dec4u avatar Nov 29 '18 02:11 rahman13dec4u

Well, I don't know what to say. Apart from a couple of quirks (i.e. the type should be gauge, not counter; and you should drop the value_label if your query only returns one value per row) everything else looks fine. Maybe apart from the YAML indentation, but that could simply be the copy-pasta.

BTW, there is a very thoroughly commented configuration example at https://github.com/free/sql_exporter/blob/master/documentation/sql_exporter.yml . You may use it as a reference, or source for copy-pasting bits and pieces.

Anyway, if you actually started SQL Exporter correctly and it actually loaded your configuration (you can check that in the console output, it should say something about Loading configuration from and Loaded collector from), then any errors should also be output to the console. Do you see anything there?

free avatar Dec 03 '18 16:12 free