How to query for null values?

I have some job data I’m storing in elasticsearch, lets say:
{
name : (optional)
status : [running/waiting]
@timestamp : …
}

I can plot a count of all running jobs with the query “status:running”, I can plot a count of all running jobs which have a name using “status:running and name:*”. How do I plot a count of all running jobs with no given name?

Think you can combine MustNot and Exists:

GET /_search
{
    "query": {
        "bool": {
            "must_not": {
                "exists": {
                    "field": "name"
                }
            }
        }
    }
}

Hi @daniellee,

How could I do that in Grafana? I mean, how can we apply mustnot and exists in grafana? In my case I’m trying not to show null values in the Graph panel, so I’d like to use exists.

Good question. Hard to remember the details 5 months later but maybe with these lucene extensions:

_exists_ did the trick, thanks :slight_smile:

1 Like