Skip to content

Commit

Permalink
Adjust documentation + examples
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed Jan 4, 2018
1 parent bdc2f4b commit 2f1bd3b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,6 @@ The exporter contains features that are currently experimental and may change wi
To use these features, either set the `-enable-experimental` flag or add a `enable_experimental` option
to your configuration file.

### Aggregation by request path

Collecting metrics by the requested resource path has been discussed in #14. Directly
adding the requested path as a label is problematic since the set of possible values is
infinitely large. For this reason, you can specify a set of `routes` in your
configuration file, which is basically a list of regular expressions; if one of these matches
a request path, the regular expression will be added as a label to the respective metric:

```hcl
namespace "app-1" {
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
source_files = [
"/var/log/nginx/app1/access.log"
]
routes = [
"^/users/[0-9]+",
"^/profile",
"^/news"
]
}
```

### Dynamic re-labeling

Re-labeling lets you add arbitrary fields from the parsed log line as labels to your metrics.
Expand All @@ -138,6 +116,28 @@ The `whitelist` property is optional; if set, only the supplied values will be a
All other values will be subsumed under the `"other"` label value. See #16 for a more detailed
discussion around the reasoning.

Dynamic relabeling also allows you to aggregate your metrics by request path (which replaces
the experimental feature originally introduced in #23):

```hcl
namespace "app-1" {
// ...
relabel "request_uri" {
from = "request"
split = 2
match "^/users/[0-9]+" {
replacement = "/users/:id"
}
match "^/profile" {
replacement = "/profile"
}
}
}
```

Running the collector
---------------------

Expand Down
11 changes: 8 additions & 3 deletions example-config.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ namespace "nginx" {
// whitelist = ["-", "user1", "user2"]
}

routes = [
"^/users/[0-9]+"
]
relabel "request_uri" {
from = "request"
split = 2

match "^users/[0-9]+" {
replacement = "/users/:id"
}
}
}

0 comments on commit 2f1bd3b

Please sign in to comment.