Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logparser: regexp with lookahead #2178

Closed
ma2thieu opened this issue Dec 20, 2016 · 1 comment · Fixed by #2454
Closed

logparser: regexp with lookahead #2178

ma2thieu opened this issue Dec 20, 2016 · 1 comment · Fixed by #2454
Milestone

Comments

@ma2thieu
Copy link

Bug report

I want to filter out all the logs from bots, so I setup a custom pattern with a regex that only match user-agent that don't contain the words "bot" and "crawl"

Relevant telegraf.conf:

NOBOT ((?!bot|crawl).)*
COMBINED_GEOIP_LOG_FORMAT %{CLIENT:client_ip} %{NOTSPACE:ident:drop} %{NOTSPACE:auth:drop} \[%{HTTPDATE:ts:ts-httpd}\] "(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:drop})?|%{DATA})" %{NUMBER:resp_code:tag} (?:%{NUMBER:resp_bytes:drop}|-) %{QS:referrer:drop} "%{NOBOT:agent:drop}" %{QS:country_code:tag} %{QS:country_name:drop}

System info:

Telegraf v1.1.1
Debian 8

Steps to reproduce:

telegraf -config /etc/telegraf/telegraf.conf

Expected behavior:

import only logs where agent doesn't contain the word bot or crawl

Actual behavior:

import nothing

Additional info:

http://stackoverflow.com/questions/41180872/custom-pattern-to-drop-bots-when-importing-logs-into-influxdb/41189447#41189447

@sparrc sparrc changed the title logparser : regexp with lookahead don't work logparser: regexp with lookahead Dec 20, 2016
@sparrc
Copy link
Contributor

sparrc commented Dec 20, 2016

I don't think we'll be able to do much unless Go itself supports lookaheads, but we should at least return an error message if the regex pattern compile fails as it does here.

@sparrc sparrc added this to the 1.3.0 milestone Dec 20, 2016
sparrc added a commit that referenced this issue Feb 21, 2017
sparrc added a commit that referenced this issue Feb 22, 2017
sparrc added a commit that referenced this issue Feb 22, 2017
sparrc added a commit that referenced this issue Feb 28, 2017
ssorathia pushed a commit to ssorathia/telegraf that referenced this issue Mar 25, 2017
eldadzack pushed a commit to eldadzack/telegraf that referenced this issue Mar 27, 2017
vlamug pushed a commit to vlamug/telegraf that referenced this issue May 30, 2017
maxunt pushed a commit that referenced this issue Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants