Docker Community Forums

Share and learn in the Docker community.

Connecting from container to sql server host instance

Hi…
I’m playing a little bit with this great sw…
and I’m using a docker-compose.yml file for lunch my app.
I got a problem with “sql_server_exporter”…
Using it totally external on my host… I haven’t any problem and from Prometheous I see every metrics.
On the other side… when I play it ike a docker app, there is no way to connect on my SQL SERVER host instance.

docker-compose.yml
I tried also with

    ports:
      - 9966:9966
      - 1433:1433
version: "3.7"
 
services:
  sql_server_exporter:
    image: mindflavor/prometheus_sql_server_exporter:latest
    container_name: sql_server_exporter
    volumes:
            - ./sql_server_exporter/exporter_config.json:/config/config.json
    ports:
      - 9966:9966
      
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    volumes:
            - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
            - prometheus-storage:/prometheus
    ports:
      - 9090:9090
      
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    volumes:
            - ./grafana/grafana.ini:/etc/grafana/grafana.ini
            - ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yaml
            - grafana-storage:/var/lib/grafana
    ports:
      - 3000:3000
      
volumes:
    grafana-storage:
      external: true
    prometheus-storage:
      external: true

Prometheous.yml

global: 
  evaluation_interval: 15s
  scrape_interval: 15s
  scrape_timeout: 10s
  
scrape_configs: 
  - job_name: prometheus
    static_configs: 
      - targets: ['localhost:9090']
      
  - job_name: sql_server_exporter
    static_configs: 
      - targets: ['host.docker.internal:9966']
        labels:
          sqlinstance: hp-probook
          
  - job_name: windows_exporter
    static_configs: 
      - targets: ['host.docker.internal:9182']
        labels:
          sqlhost: hp-probook

exporter_config.json
(I try also with localhost… )

{
    "port": 9966,
    "instanceTotalTimeout": 10,
    "instances": [
        {
            "connectionString": "Server=host.docker.internal;User Id=docker;Password=docker"
        }
    ],

Seems to me an errore between container and my HOST.
I tried also opening all the 3 port (1433, 9090, 9966) but no way out.
Only like an external application that live on my windows workstation seems to be all run perfectly… and I see every metric from docker app.

I hope someone can help me.
ALEN

Is there any error message in the container logs? The hostname looks good but I don’t know this sql server exporter