Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/issue-212
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed Dec 22, 2021
2 parents 49638b4 + f09c9dc commit 4951ce2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
version: v1.0.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.githubToken }}
12 changes: 7 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dockers:
- docker.pkg.github.com/martin-helmich/prometheus-nginxlog-exporter/exporter:v{{ .Major }}
- docker.pkg.github.com/martin-helmich/prometheus-nginxlog-exporter/exporter:v{{ .Major }}.{{ .Minor }}
- docker.pkg.github.com/martin-helmich/prometheus-nginxlog-exporter/exporter:{{ .Tag }}
binaries:
ids:
- prometheus-nginxlog-exporter
goos: linux
goarch: amd64
Expand All @@ -46,9 +46,11 @@ nfpms:
dependencies:
- systemd
bindir: /usr/sbin
files:
res/package/prometheus-nginxlog-exporter.service: /lib/systemd/system/prometheus-nginxlog-exporter.service
config_files:
res/package/default-config.hcl: /etc/prometheus-nginxlog-exporter.hcl
contents:
- src: res/package/prometheus-nginxlog-exporter.service
dst: /lib/systemd/system/prometheus-nginxlog-exporter.service
- src: res/package/default-config.hcl
dst: /etc/prometheus-nginxlog-exporter.hcl
type: config|noreplace
scripts:
postinstall: res/package/scripts/postinstall.sh
11 changes: 11 additions & 0 deletions features/issues.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ Feature: Various issues reported in the bug tracker remain solved
"""
Then the exporter should report value 3 for metric http_parse_errors_total{vhost="test"}
And the exporter should report value 2 for metric http_parse_errors_total{vhost="test2"}

Scenario: Issue 224: Missing float values
Given a running exporter listening with configuration file "test-config-issue217.yaml"
When the following HTTP request is logged to "access.log"
"""
www.example.com 10.0.0.1 - - [27/Oct/2021:06:00:14 +0200] "GET /websocket HTTP/1.1" 200 552 "-" "SomeUserAgentString" 0.000 "1.000, -, 2.000" . TLSv1.3/TLS_AES_256_GCM_SHA384 1234567890 www.example.com
www.example.com 10.0.0.2 - - [27/Oct/2021:06:00:15 +0200] "GET /websocket HTTP/1.1" 200 552 "-" "AnotherUserAgent" - "1.000" . TLSv1.3/TLS_AES_256_GCM_SHA384 1234567890 www.example.com
"""
Then the exporter should report value 0 for metric test_parse_errors_total
Then the exporter should report value 4 for metric test_http_upstream_time_seconds_sum{method="GET",status="200"}

8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ func floatFromFieldsMulti(fields map[string]string, name string) (float64, bool,
for _, v := range strings.Split(val, ",") {
v = strings.TrimSpace(v)

if v == "-" {
continue
}

f, err := strconv.ParseFloat(v, 64)
if err != nil {
return 0, false, fmt.Errorf("value '%s' could not be parsed into float", val)
Expand All @@ -463,6 +467,10 @@ func floatFromFields(fields map[string]string, name string) (float64, bool, erro
return 0, false, nil
}

if val == "-" {
return 0, false, nil
}

f, err := strconv.ParseFloat(val, 64)
if err != nil {
return 0, false, fmt.Errorf("value '%s' could not be parsed into float", val)
Expand Down

0 comments on commit 4951ce2

Please sign in to comment.