Created
February 8, 2021 19:20
-
-
Save haproxytechblog/303b10b129cd21e115d66bdd98d7c7d1 to your computer and use it in GitHub Desktop.
Using HAProxy as an API Gateway, Part 4 Metrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend stats | |
bind :8404 | |
stats enable | |
stats uri / | |
stats refresh 10s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
stats socket /var/run/haproxy.sock user haproxy group haproxy mode 660 level admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
stats socket ipv4@127.0.0.1:9999 user haproxy group haproxy mode 660 level admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo "show stat json" | socat tcp-connect:127.0.0.1:9999 - | python3 -m json.tool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ watch 'echo "show stat" | socat tcp-connect:127.0.0.1:9999 - | cut -d "," -f 1-2,16,18,43,44,47,61 | column -s, -t' | |
# pxname svname wretr status hrsp_4xx hrsp_5xx req_rate rtime | |
fe_api FRONTEND OPEN 0 0 10 | |
be_api s1 0 UP 0 0 4 | |
be_api s2 0 UP 0 0 4 | |
be_api s3 0 UP 0 0 5 | |
be_api s4 0 UP 0 0 5 | |
be_api s5 0 UP 0 0 5 | |
be_api BACKEND 0 UP 0 0 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ haproxy -vv | grep "Prometheus exporter" | |
Built with the Prometheus exporter as a service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend stats | |
bind :8404 | |
stats enable | |
stats uri / | |
stats refresh 5s | |
http-request use-service prometheus-exporter if { path /metrics } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global: | |
scrape_interval: 5s | |
evaluation_interval: 5s | |
scrape_configs: | |
- job_name: 'haproxy' | |
static_configs: | |
- targets: ['172.25.0.11:8404'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
stats socket ipv4@*:9999 user haproxy group haproxy mode 660 level admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ metricbeat modules enable haproxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output.elasticsearch: | |
hosts: ["172.25.0.19:9200"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- module: haproxy | |
metricsets: ["info", "stat"] | |
period: 10s | |
hosts: ["tcp://172.25.0.11:9999"] | |
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo service metricbeat start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment