重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

标题: prometheus的sqlserver多套部署脚本与步骤 [打印本页]

作者: mahan    时间: 3 天前
标题: prometheus的sqlserver多套部署脚本与步骤
SQLSERVER:

[root@prometheus ~]# more /etc/systemd/system/sql_exporter@.service
[Unit]
Description=SQL Server Exporter for Prometheus
After=network.target

[Service]
User=root
ExecStart=/opt/sql_exporter/sql_exporter --config.file="/opt/sql_exporter/sql_exporter_%i.yml" -web.listen-address=":%i"
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target



[root@prometheus ~]# cd /opt/sql_exporter/
[root@prometheus sql_exporter]# ls -ltr
total 96416
-rwxr-xr-x 1 1001 oracle 98672802 Jun  7 17:27 sql_exporter
-rw-r--r-- 1 1001 oracle    24655 Jun  7 17:27 README.md
-rw-r--r-- 1 1001 oracle     1104 Jun  7 17:27 LICENSE
-rw-r--r-- 1 1001 oracle     1859 Jun 11 10:28 sql_exporter_9400.yml
-rw-r--r-- 1 root root       6495 Jun 11 10:34 mssql_standard.collector.yml.bak
-rw-r--r-- 1 1001 oracle     7344 Jun 11 10:35 mssql_standard.collector.yml
[root@prometheus sql_exporter]# more sql_exporter_9400.yml
# Global defaults.
global:
  # If scrape_timeout <= 0, no timeout is set unless Prometheus provides one. The default is 10s.
  scrape_timeout: 10s
  # Subtracted from Prometheus' scrape_timeout to give us some headroom and prevent Prometheus from timing out first.
  scrape_timeout_offset: 500ms
  # Minimum interval between collector runs: by default (0s) collectors are executed on every scrape.
  min_interval: 0s
  # Maximum number of open connections to any one target. Metric queries will run concurrently on multiple connections,
  # as will concurrent scrapes.
  max_connections: 3
  # Maximum number of idle connections to any one target. Unless you use very long collection intervals, this should
  # always be the same as max_connections.
  max_idle_connections: 3
  # Maximum number of maximum amount of time a connection may be reused. Expired connections may be closed lazily before reuse.
  # If 0, connections are not closed due to a connection's age.
  max_connection_lifetime: 5m
  # Interval between database pings. By default (0s) ping every time when call target.ping().
  ping_interval: 30s

# The target to monitor and the collectors to execute on it.
target:
  # Data source name always has a URI schema that matches the driver name. In some cases (e.g. MySQL)
  # the schema gets dropped or replaced to match the driver expected DSN format.
  data_source_name: 'sqlserver://prometheus:sztech_4U@192.168.77.114:1433/master'

  # Collectors (referenced by name) to execute on the target.
  # Glob patterns are supported (see <https://pkg.go.dev/path/filepath#Match> for syntax).
  collectors: [mssql_*]

# Collector files specifies a list of globs. One collector definition is read from each matching file.
# Glob patterns are supported (see <https://pkg.go.dev/path/filepath#Match> for syntax).
collector_files:
  - "*.collector.yml"




[root@prometheus sql_exporter]# systemctl status sql_exporter@9400.service
sql_exporter@9400.service - SQL Server Exporter for Prometheus
     Loaded: loaded (/etc/systemd/system/sql_exporter@.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2026-06-11 11:17:13 CST; 1h 4min ago
   Main PID: 58673 (sql_exporter)
      Tasks: 10 (limit: 21616)
     Memory: 21.5M
     CGroup: /system.slice/system-sql_exporter.slice/sql_exporter@9400.service
             └─ 58673 /opt/sql_exporter/sql_exporter --config.file=/opt/sql_exporter/sql_exporter_9400.yml -web.listen-address=:9400

Jun 11 11:17:13 prometheus systemd[1]: Started SQL Server Exporter for Prometheus.
Jun 11 11:17:13 prometheus sql_exporter[58673]: time=2026-06-11T11:17:13.559+08:00 level=WARN source=main.go:101 msg="Starting SQL exporter" versionInfo="(version=0.24.1, branch=HEAD, revision=266712dd6981639d21eb7e8ab4067c605e37eb9>
Jun 11 11:17:13 prometheus sql_exporter[58673]: time=2026-06-11T11:17:13.566+08:00 level=INFO source=tls_config.go:354 msg="Listening on" address=[::]:9400
Jun 11 11:17:13 prometheus sql_exporter[58673]: time=2026-06-11T11:17:13.566+08:00 level=INFO source=tls_config.go:357 msg="TLS is disabled." http2=false address=[::]:9400






欢迎光临 重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2