I followed this document : https://prometheus.io/docs/guides/query-log/ to enable query logs on our prometheus server, so I edited the configuration as follows:
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
query_log_file: /app/prometheus/query.log
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
# Load rules once and periodically evaluate them according to the global evaluation_interval.
rule_files:
- "prometheus_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label job=<job_name> to any timeseries scraped from this config.
- job_name: 'prometheus'
scrape_timeout: 30s
scrape_interval: 60s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_prometheus'
scrape_timeout: 30s
scrape_interval: 60s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9100']
- job_name: 'grafana'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
# mettre ALB grafana
- targets: ['${grafana_dns}']
- job_name: 'sqs_exporter'
scrape_interval: 5m
scrape_timeout: 2m
static_configs:
- targets: ['localhost:9434']
- job_name: 'cloudwatch_exporter'
scrape_interval: 5m
scrape_timeout: 2m
static_configs:
- targets: ['localhost:9106']
- job_name: '_metrics'
metric_relabel_configs:
relabel_configs:
- source_labels:
- __meta_ec2_platform
action: keep
regex: .*windows.*
- action: labelmap
regex: __meta_ec2_tag_(.*)
replacement: \$1
ec2_sd_configs:
- region: ${aws_region}
port: 9543
role_arn: arn:aws:iam::xxxxxxxxxxxx:role/prometheus_readonly
filters:
- name: tag:app
values:
- cloudapp
- region: ${aws_region}
port: 9543
role_arn: arn:aws:iam::xxxxxxxxxxxxx:role/prometheus_readonly
filters:
- name: tag:longcode
values:
- apps*emphasized text*
- job_name: 'cadvisor'
static_configs:
- targets: ['localhost:8080']
- job_name: 'elasticbeanstalk_exporter'
static_configs:
- targets: ['localhost:9552']
Once I finish editing the configuration file I reload the prometheus conf by this command:
sudo killall -HUP prometheus
Then :
sudo systemctl status prometheus -l
Here is the error I get:
Jul 23 14:39:23 ip-prometheus: level=error ts=2020-07-23T14:39:23.931Z caller=main.go:583 msg="Error reloading config" err="couldn't load configuration (--config.file=\"/usr/local/prometheus/prometheus/prometheus.yml\"): parsing YAML file /usr/local/prometheus/prometheus/prometheus.yml: yaml: unmarshal errors:\n line 5: field query_log_file not found in type config.plain"
Could you please help?
What is the prometheus version?
you can use 「query_log_file」 since v2.16.0.
https://github.com/coreos/prometheus-operator/issues/3025