Skip to content

Commit b56b6ed

Browse files
committed
fix(log): fix ip address in request by ip metrics
1 parent 7e0c9ec commit b56b6ed

5 files changed

Lines changed: 73 additions & 83 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ docker pull daffaputranarendra/sysy:v0.0.2
2222
Add Below Configuration to your existing nginx.conf. For example, check config directory in this repository.
2323

2424
```nginx
25-
log_format syslog_format '$http_host\t'
25+
log_format syslog_format '$remote_addr\t'
2626
'$request_method\t'
2727
'$status\t'
2828
'$request_completion\t'

config/Nginx Monitoring-1755763182476.json renamed to config/Nginx Monitoring-1755829532920.json

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "grafana",
1616
"id": "grafana",
1717
"name": "Grafana",
18-
"version": "12.2.0-17027759091"
18+
"version": "12.1.1"
1919
},
2020
{
2121
"type": "datasource",
@@ -125,7 +125,7 @@
125125
"textMode": "value",
126126
"wideLayout": true
127127
},
128-
"pluginVersion": "12.2.0-17027759091",
128+
"pluginVersion": "12.1.1",
129129
"targets": [
130130
{
131131
"datasource": {
@@ -221,18 +221,18 @@
221221
"sort": "none"
222222
}
223223
},
224-
"pluginVersion": "12.2.0-17027759091",
224+
"pluginVersion": "12.1.1",
225225
"targets": [
226226
{
227+
"datasource": {
228+
"type": "prometheus",
229+
"uid": "${DS_PROMETHEUS}"
230+
},
227231
"editorMode": "code",
228232
"expr": "rate(syslog_responses_by_class_total{class=\"2xx\"}[$__rate_interval])",
229233
"legendFormat": "{{class}}",
230234
"range": true,
231-
"refId": "A",
232-
"datasource": {
233-
"type": "prometheus",
234-
"uid": "${DS_PROMETHEUS}"
235-
}
235+
"refId": "A"
236236
}
237237
],
238238
"title": "2xx",
@@ -318,18 +318,18 @@
318318
"sort": "none"
319319
}
320320
},
321-
"pluginVersion": "12.2.0-17027759091",
321+
"pluginVersion": "12.1.1",
322322
"targets": [
323323
{
324+
"datasource": {
325+
"type": "prometheus",
326+
"uid": "${DS_PROMETHEUS}"
327+
},
324328
"editorMode": "code",
325329
"expr": "rate(syslog_responses_by_class_total{class=\"3xx\"}[$__rate_interval])",
326330
"legendFormat": "{{class}}",
327331
"range": true,
328-
"refId": "A",
329-
"datasource": {
330-
"type": "prometheus",
331-
"uid": "${DS_PROMETHEUS}"
332-
}
332+
"refId": "A"
333333
}
334334
],
335335
"title": "3xx",
@@ -415,18 +415,18 @@
415415
"sort": "none"
416416
}
417417
},
418-
"pluginVersion": "12.2.0-17027759091",
418+
"pluginVersion": "12.1.1",
419419
"targets": [
420420
{
421+
"datasource": {
422+
"type": "prometheus",
423+
"uid": "${DS_PROMETHEUS}"
424+
},
421425
"editorMode": "code",
422426
"expr": "rate(syslog_responses_by_class_total{class=\"4xx\"}[$__rate_interval])",
423427
"legendFormat": "{{class}}",
424428
"range": true,
425-
"refId": "A",
426-
"datasource": {
427-
"type": "prometheus",
428-
"uid": "${DS_PROMETHEUS}"
429-
}
429+
"refId": "A"
430430
}
431431
],
432432
"title": "4xx",
@@ -512,18 +512,18 @@
512512
"sort": "none"
513513
}
514514
},
515-
"pluginVersion": "12.2.0-17027759091",
515+
"pluginVersion": "12.1.1",
516516
"targets": [
517517
{
518+
"datasource": {
519+
"type": "prometheus",
520+
"uid": "${DS_PROMETHEUS}"
521+
},
518522
"editorMode": "code",
519523
"expr": "rate(syslog_responses_by_class_total{class=\"5xx\"}[$__rate_interval])",
520524
"legendFormat": "{{class}}",
521525
"range": true,
522-
"refId": "A",
523-
"datasource": {
524-
"type": "prometheus",
525-
"uid": "${DS_PROMETHEUS}"
526-
}
526+
"refId": "A"
527527
}
528528
],
529529
"title": "5xx",
@@ -609,18 +609,18 @@
609609
"sort": "none"
610610
}
611611
},
612-
"pluginVersion": "12.2.0-17027759091",
612+
"pluginVersion": "12.1.1",
613613
"targets": [
614614
{
615+
"datasource": {
616+
"type": "prometheus",
617+
"uid": "${DS_PROMETHEUS}"
618+
},
615619
"editorMode": "code",
616620
"expr": "rate(syslog_request_latency_seconds_sum[$__rate_interval])\r\n/\r\nrate(syslog_request_latency_seconds_count[$__rate_interval])",
617621
"legendFormat": "{{uri}}",
618622
"range": true,
619-
"refId": "A",
620-
"datasource": {
621-
"type": "prometheus",
622-
"uid": "${DS_PROMETHEUS}"
623-
}
623+
"refId": "A"
624624
}
625625
],
626626
"title": "Average Latency",
@@ -706,21 +706,21 @@
706706
"sort": "none"
707707
}
708708
},
709-
"pluginVersion": "12.2.0-17027759091",
709+
"pluginVersion": "12.1.1",
710710
"targets": [
711711
{
712-
"editorMode": "code",
713-
"expr": "rate(nginx_requests_total[$__rate_interval])",
714-
"legendFormat": "Request Rate",
715-
"range": true,
716-
"refId": "A",
717712
"datasource": {
718713
"type": "prometheus",
719714
"uid": "${DS_PROMETHEUS}"
720-
}
715+
},
716+
"editorMode": "code",
717+
"expr": "rate(nginx_requests_total[$__rate_interval])",
718+
"legendFormat": "Requests Total Rate",
719+
"range": true,
720+
"refId": "A"
721721
}
722722
],
723-
"title": "Request Rate",
723+
"title": "Requests Total Rate",
724724
"type": "timeseries"
725725
},
726726
{
@@ -803,18 +803,18 @@
803803
"sort": "none"
804804
}
805805
},
806-
"pluginVersion": "12.2.0-17027759091",
806+
"pluginVersion": "12.1.1",
807807
"targets": [
808808
{
809+
"datasource": {
810+
"type": "prometheus",
811+
"uid": "${DS_PROMETHEUS}"
812+
},
809813
"editorMode": "builder",
810814
"expr": "rate(syslog_requests_by_ip[$__rate_interval])",
811815
"legendFormat": "{{ip}}",
812816
"range": true,
813-
"refId": "A",
814-
"datasource": {
815-
"type": "prometheus",
816-
"uid": "${DS_PROMETHEUS}"
817-
}
817+
"refId": "A"
818818
}
819819
],
820820
"title": "Request By IP Address",
@@ -900,18 +900,18 @@
900900
"sort": "none"
901901
}
902902
},
903-
"pluginVersion": "12.2.0-17027759091",
903+
"pluginVersion": "12.1.1",
904904
"targets": [
905905
{
906+
"datasource": {
907+
"type": "prometheus",
908+
"uid": "${DS_PROMETHEUS}"
909+
},
906910
"editorMode": "builder",
907911
"expr": "nginx_active_connections",
908912
"legendFormat": "{{__name__}}",
909913
"range": true,
910-
"refId": "A",
911-
"datasource": {
912-
"type": "prometheus",
913-
"uid": "${DS_PROMETHEUS}"
914-
}
914+
"refId": "A"
915915
},
916916
{
917917
"datasource": {
@@ -973,6 +973,6 @@
973973
"timezone": "browser",
974974
"title": "Nginx Monitoring",
975975
"uid": "a5898e10-818f-4db4-bfc4-8431723d512a",
976-
"version": 34,
976+
"version": 2,
977977
"weekStart": ""
978978
}

config/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
events {}
22
http {
3-
log_format syslog_format '$http_host\t'
3+
log_format syslog_format '$remote_addr\t'
44
'$request_method\t'
55
'$status\t'
66
'$request_completion\t'

go.mod

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ module github.com/daffadon/sysy
22

33
go 1.24.6
44

5-
require github.com/prometheus/client_golang v1.23.0
5+
require (
6+
github.com/joho/godotenv v1.5.1
7+
github.com/prometheus/client_golang v1.23.0
8+
)
69

710
require (
811
github.com/beorn7/perks v1.0.1 // indirect
912
github.com/cespare/xxhash/v2 v2.3.0 // indirect
10-
github.com/joho/godotenv v1.5.1 // indirect
11-
github.com/mattn/go-colorable v0.1.13 // indirect
12-
github.com/mattn/go-isatty v0.0.19 // indirect
1313
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
1414
github.com/prometheus/client_model v0.6.2 // indirect
1515
github.com/prometheus/common v0.65.0 // indirect
1616
github.com/prometheus/procfs v0.17.0 // indirect
17-
github.com/rs/zerolog v1.34.0 // indirect
18-
github.com/sirupsen/logrus v1.9.3 // indirect
1917
golang.org/x/sys v0.35.0 // indirect
2018
google.golang.org/protobuf v1.36.7 // indirect
2119
)

go.sum

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
22
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
33
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
44
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5-
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
6-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
76
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8-
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
7+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
8+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
99
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
1010
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
11-
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
12-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
13-
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
14-
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
15-
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
11+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
12+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
13+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
14+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
1615
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
1716
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
18-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
17+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1918
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2019
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
2120
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
@@ -25,20 +24,13 @@ github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2
2524
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
2625
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
2726
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
28-
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
29-
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
30-
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
31-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
32-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
33-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
34-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
35-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
36-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
37-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38-
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
28+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
29+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
30+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
3931
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
4032
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
4133
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
4234
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
43-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
44-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
35+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
36+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)