I'm trying to create a metric that lists how long a development pipeline has been broken for. I compute this field in the script I use to upload my documents with. The field is marked as relative time in my index. What I'd really like for this to do is when a pipeline breaks, we mark the time in the field "results.failing_since". Then, when the pipeline isn't broken, meaning all my tests pass, then the field is "null".
When I add this to a metric, it always skips over the "null" documents. Then I created a script to use, that when the field is "null", I'll just pass a string saying "pipeline not broken". However, that fails because apparently the metric visualization is expecting a number. And if I just have it return a 0, instead, then I get an exception:
class_cast_exception: org.elasticsearch.script.JodaCompatibleZonedDateTime cannot be cast to java.lang.Number"
When I try to do this in a data table, then the timestamp won't be rendered as relative time. AND, the field is missing on some pipelines, too. So, I have this state where a field can or cannot be present, can or cannot be null, and should be rendered as relative time.
I've tried something similar to this on a datatable. But this can still result in an exception, and the datatable won't format this as relative time (if it isn't busy throwing exceptions, that is):
{
"script": "if (doc.containsKey('results.failing_since') && doc['results.failing_since'].size() != 0 && doc['results.failing_since'].value != null) { return doc['results.failing_since'].value;} else { return 'Not failing.';}"
}
How do I get this data visualized!!!