Comments (7)
Hi! Try something like this
...
match: "%{ERROR_MESSAGE_PATTERN:error}."
value: '{{ if eq .error "string to compare" }}1{{ else }}0{{ end }}'
...
from grok_exporter.
thanks for the reply @ashevchuk123
I get this
failed to initialize metric error_in_log: Pattern %{ERROR_MESSAGE_PATTERN:error} not defined.
from grok_exporter.
Because you need to initialize patterns (variables with regexes) and include them in config.
imports:
- type: grok_patterns
file: /path/to/patterns/file
in this file you may create patterns for your error, for example:
ERROR_MESSAGE_PATTERN (regex_for_your_error_here)
You may find examples for patterns in the zip archive provided in the release.
from grok_exporter.
OK thanks so much for the help : )
from grok_exporter.
my issue is that if the string is not found I don't get the metric error_in_log
is there a way to have it to 0 and if the string is found then its 1 value: '{{ if eq .error "string to compare" }}1{{ else }}0{{ end }}'
this didn't work
from grok_exporter.
and im trying it with multiple metrics
global:
config_version: 3
input:
type: file
paths:
- /var/logs/logfile.log
- /var/logs1/logfile.log
readall: true
imports:
- type: grok_patterns
dir: /path/to/patterns/file
metrics:
- type: gauge
name: error_in_log
help: Error has been found in log.
match: "%{ERROR_MESSAGE_PATTERN:error}."
value: '{{ if eq .error "string to compare" }}1{{ else }}0{{ end }}'
path: /var/logs/logfile.log
labels:
logfile: '{{base .logfile}}'
- type: gauge
name: error_in_log_1
help: Error has been found in log 1.
match: "%{ERROR_MESSAGE_PATTERN:error}."
value: '{{ if eq .error "string to compare" }}1{{ else }}0{{ end }}'
path: /var/logs1/logfile.log
labels:
logfile: '{{base .logfile}}'
server:
port: 9144
is this the right way to do it ?
from grok_exporter.
and I have in my patterns
ERROR_MESSAGE_PATTERN (.*)
but I always get 0
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?
- 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.