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

Multiple formats support #230

Open
pawellrus opened this issue Nov 30, 2021 · 3 comments
Open

Multiple formats support #230

pawellrus opened this issue Nov 30, 2021 · 3 comments

Comments

@pawellrus
Copy link

Is your feature request related to a problem? Please describe.
Some log strings doesn't contain $upstream_response_time value. So exporter throws many errors like "error while parsing $upstream_response_time: value '' could not be parsed into float"

Describe the solution you'd like
I would be nice if exporter could parse string against several formats (without $upstream_response_time for example) and select more apropriate format for each string.

@martin-helmich
Copy link
Owner

Thanks for the suggestion! 👍 The exporter was built under the general assumption that it would be fed uniform log lines. Supporting multiple log formats in a single file is not a priority for me ATM, but I'd be willing to accept pull requests for this feature, provided that they're backwards-compatible and have test coverage.

@pawellrus
Copy link
Author

pawellrus commented Jan 12, 2022

@martin-helmich, hello. Another one question regarding this issue. If we can have only one format template, may be we can define possible null values inside. I mean something like that:

format = "$remote_addr - $remote_user [$time_local] \"$request\" ($status|) ($body_bytes_sent|) \"($http_referer|)\" \"($http_user_agent|)\" \"($http_x_forwarded_for|)\""

Or it should not work?

UPD: already tested this - not possible. Seems that only way to get rid of exceptions like "error while parsing $upstream_response_time: value '' could not be parsed into float" is to implement multiple formats. :(

@Nereis
Copy link

Nereis commented Oct 13, 2022

You may want to try to define your nginx pattern with the nullable field at the end. It may work since the exporter won't have any else to parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants