TransWikia.com

Prometheus sql doesn't seem to execute the query. Always display -1 as result

Stack Overflow Asked by Valli on November 7, 2021

I am using https://github.com/chop-dbhi/prometheus-sql for prometheus to execute sql queries. The containers are all up and running.
The value of query_result_example is always -1 (query-value-on-error = -1 as configured in prometheus-sql.yml)provided the actual value is 3.

I have executed the same query on Azure Data studio with same connection and credentials which returns 3.

I am unable to figure out where i am going wrong. Any help is appreciated.

docker-compose file:

prometheus:
    image: prom/prometheus:v2.19.2
    container_name: prometheus
    volumes:
      - ./prometheus:/etc/prometheus
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--storage.tsdb.retention.time=200h'
      - '--web.enable-lifecycle'
    restart: unless-stopped
    ports:
      - "9090:9090"
    expose:
      - 9090
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

sql-server-db:
    container_name: sql-server-db
    image: microsoft/mssql-server-linux:2017-latest
    ports:
      - "1433:1433"
    expose:
      - 1433
    environment:
      SA_PASSWORD: "Password"
      ACCEPT_EULA: "Y"

  sqlagent:
    image: dbhi/sql-agent
    container_name: sqlagent
    ports:
      - "5000:5000"
    expose:
      - 5000

  prometheussql:
    image: dbhi/prometheus-sql
    container_name: prometheussql
    volumes:
      - ${PWD}/prometheus-sql.yml:/prometheus-sql.yml
      - ${PWD}/test/queries.yml:/queries.yml
    links:
      - sqlagent:sqlagent
    command: >
      -service http://sqlagent:5000
      -config /prometheus-sql.yml
    ports:
      - "8080:8080"
    expose:
      - 8080
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

queries.yml: (the below query has to return 3)

- example:

    sql: >
        select count(*) from MSreplication_options
    interval: 5m

prometheus-sql.yml

defaults:
  data-source: my-ds
  query-interval: 10s
  query-timeout: 5s
  query-value-on-error: -1

# Defined data sources
data-sources:
  my-ds:
    driver: mssql
    properties:
      host: localhost
      port: 1433
      user: sa
      password: Password
      database: master

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP