Comments (5)
Hi, thank you very much! I am not sure if I understand your question exactly. Could you give me an example?
from grok_exporter.
Appreciate you looking into this. Here is a simplified sample log file, should be self-explained with header:
#Fields: date time method status substatus timetaken
2016-06-15 22:00:00 POST 200 0 404
2016-06-15 22:00:01 POST 404 0 210
2016-06-15 22:00:03 POST 200 0 404
2016-06-15 22:00:11 POST 200 0 300
2016-06-15 22:02:41 POST 200 120 404
2016-06-15 22:02:41 POST 200 0 404
2016-06-15 22:02:41 POST 200 0 240
2016-06-15 22:02:41 POST 200 0 404
2016-06-15 22:02:41 POST 200 0 404
2016-06-15 22:02:42 POST 200 120 512
2016-06-15 22:02:42 POST 200 0 404
2016-06-15 22:02:42 POST 200 0 404
2016-06-15 22:02:43 POST 200 0 120
2016-06-15 22:02:43 POST 200 120 404
2016-06-15 22:02:43 POST 200 0 98
2016-06-15 22:02:43 POST 200 0 404
2016-06-15 22:02:43 POST 200 0 90
2016-06-15 22:02:43 POST 200 0 404
2016-06-15 22:02:44 POST 200 0 120
2016-06-15 22:02:44 OPTIONS 200 0 661
2016-06-15 22:02:44 POST 200 0 404
and snippet of the config file:
metrics:
- type: counter
name: log_status_count
help: Total number of logs, partitioned by status code
match: '%{TIMESTAMP_ISO8601:log_timestamp} %{WORD:method} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:timetaken}'
labels:
- grok_field_name: response
prometheus_label: http_status_code
- type: counter
name: log_substatus_count
help: Total number of logs, partitioned by substatus code
match: '%{TIMESTAMP_ISO8601:log_timestamp} %{WORD:method} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:timetaken}'
labels:
- grok_field_name: subresponse
prometheus_label: http_substatus_code
from grok_exporter.
Thanks for the example. It is currently not possible to combine multiple grok fields into one Prometheus label. I think it would be a useful feature though, and I am planning to do a new release between Christmas and New Year's, so it should be possible soon :)
In the meantime, if the two fields are next to each other as in your simplified log, you could define a Grok pattern spanning both fields, like RESPONSE_AND_SUBRESPONSE %{NUMBER:response} %{NUMBER:subresponse}
. Then you could use %{RESPONSE_AND_SUBRESPONSE:response_and_subresponse}
in the metrics config.
from grok_exporter.
I just released v0.2.0
, which introduces a more flexible way to define labels using templates. You can now define a label like this:
labels:
http_status: '{{.response}}.{{.subresponse}}'
which should produce label values like 200.0
.
from grok_exporter.
Release v0.2.1
has even better support for templates. Closing this issue, all kinds of field combinations as label values should work now.
from grok_exporter.
Related Issues (20)
- Feature Request: Option to specify ciphers or minimum TLS version HOT 2
- fail_on_missing_logfile for missing directories HOT 3
- Feature Request : Config option to expose metrics as a .prom file
- Issue reading Multiple files:
- how to match regex upper case/lower case insensitively
- Is grok able to watch only the latest log in dir?
- how to use regex group match and use matched group name label? HOT 1
- Can the latest version cover multi-line pattern match?
- if string exists HOT 7
- Use Gauge metric to find DB connectivity status HOT 1
- Exclude char HOT 2
- Does it support Elastic Search Open Distro HOT 1
- Configure for AWS ALB/CLB Logs or Cloudfront
- grok timestamp diffrent
- grok fails on insufficient permissions when fail_on_missing_logfile is false
- mutiple depth doc support HOT 1
- How can I use FuncMap to help transform data from the log, inside a template?
- Always report counter metric (initialize to zero) HOT 1
- match fails after encountering binary text within file
- Update or let someone else maintain this repo HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grok_exporter.