Skip to content

Commit

Permalink
Add functional test cases for namespace labeling (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed May 5, 2020
1 parent 8ffdfa9 commit 2f66bb4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
15 changes: 14 additions & 1 deletion features/custom_labels.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,17 @@ Feature: Config file allows custom labels
"""
Then the exporter should report value 2 for metric nginx_http_response_count_total{method="GET",request_uri="/users/:id",status="200"}
And the exporter should report value 1 for metric nginx_http_response_count_total{method="GET",request_uri="/profile",status="200"}
And the exporter should report value 1 for metric nginx_http_response_count_total{method="GET",request_uri="",status="200"}
And the exporter should report value 1 for metric nginx_http_response_count_total{method="GET",request_uri="",status="200"}

Scenario: Namespace can be used as label
Given a running exporter listening with configuration file "test-config-namespace-label.hcl"
When the following HTTP request is logged to "access.log"
"""
172.17.0.1 - - [23/Jun/2016:16:04:20 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
"""
And the following HTTP request is logged to "access-two.log"
"""
172.17.0.1 - - [23/Jun/2016:16:04:20 +0000] "POST / HTTP/1.1" 500 612 "-" "curl/7.29.0" "-"
"""
Then the exporter should report value 1 for metric test_http_response_count_total{method="GET",status="200",test1="1-1",test2="1-2",vhost="testone"}
And the exporter should report value 1 for metric test_http_response_count_total{method="POST",status="500",test1="2-1",test2="2-2",vhost="testtwo"}
25 changes: 25 additions & 0 deletions features/test-config-namespace-label.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
port = 4040

namespace "testone" {
source_files = [".behave-sandbox/access.log"]
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
labels {
test1 = "1-1"
test2 = "1-2"
}

metrics_override = { prefix = "test" }
namespace_label = "vhost"
}

namespace "testtwo" {
source_files = [".behave-sandbox/access-two.log"]
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
labels {
test1 = "2-1"
test2 = "2-2"
}

metrics_override = { prefix = "test" }
namespace_label = "vhost"
}

0 comments on commit 2f66bb4

Please sign in to comment.