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

HumioExporter crashes if aggregated query contains no rows #30

Open
srindal opened this issue Apr 15, 2022 · 2 comments
Open

HumioExporter crashes if aggregated query contains no rows #30

srindal opened this issue Apr 15, 2022 · 2 comments

Comments

@srindal
Copy link

srindal commented Apr 15, 2022

A Humio query that ends with a count() will produce 0 if no rows were found, but a query that ends with an avg() or a sum() will produce no result if no rows were found. The latter will cause the humioexporter to crash. I suggest that the exporter either returns a zero, or removes the metric from the list of metrics until the query starts producing data.

@Crevil
Copy link
Member

Crevil commented Aug 5, 2022

I'm unable to reproduce this case.

The following query produces a 0 metric as expected. Can you share a crash log or alike from the latest version?

queries:
  - query: nothing=existing | sum(status)
    repo: humio
    interval: 1m
    metric_name: humio_status_sum

@srindal
Copy link
Author

srindal commented Aug 5, 2022

Hi, we are running with a locally modified HumioExporter to mitigate this issue. I have these log statements coming in regularly:
time="2022-08-05T10:51:11Z" level=info msg="Replace null value with 0 for #P12-i5sxxICINzcJfX0saYAtKrjZ" source="main.go:192"

This is the fix, and it works well for us. Without this fix we had plenty of crashes. I can try to run with the latest version of the Exporter and verify if I still see the problem. Btw did you try with an avg-function?

			floatValue := 0.0
			for _, f := range supportedFunctions {
				if (len(poll.Events) > 0) {
					value, ok := poll.Events[0][f]
					if !ok {
						continue
					}
					floatValue, err = parseFloat(value)
					if err != nil {
						done <- err
						return
					}
					break
				} else {
					log.Infof("Replace null value with 0 for #%v", job.Id)
				}
			}

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

No branches or pull requests

2 participants