Visualize based on dates

Hello,

I have a field that has the expiry date of an SSL certificate. The field is in form of a Date. I need to create a visualization with color to show when the date is nearing as follows:

  • Show Yellow when the date is 30 days or less, but not less than 10

  • Red when 10 days or less are remaining.

I would like to use the alert feature when the above conditions are met.

Thanks for reaching out here, @tegerei.

You may want to check out our documentation on creating a dashboard, as well as this similar post. Our documentation on alerting may also be a good thing to check out.

Hi @tegerei

sure, you can build something like that with a Lens Metric chart, leveraging the power of Lens formula.

Start with a Dashboard, then create a visualization, that will lead you to the Lens editor, and pick the Metric chart type.
Now define a Primary metric as follow:

(I've used here the @timestamp field as "field that contains the expiration date").

Now format it as Duration with the control underneath, from Milliseconds:

Screenshot 2024-05-07 at 10.11.38

I've also added a nice postfix "to renew" there, but it's not mandatory.

Next configure a dynamic coloring strategy with 2 colors:

Screenshot 2024-05-07 at 10.11.52

Just mind that values there are milliseconds (so for yellow I've set 10 days in ms: 864000):

If you want green/other color for more than 30 days, just configure a new color with a 2592000 value.

Here's the result so far:

Now save and return back to the dashboard. Click the top-right ... icon of the panel and choose Settings to configure a custom time range for the panel:

Screenshot 2024-05-07 at 10.13.11

Now the panel will always point to the last day (no matter what time range you pick in the dashboard) and will change the color based on the field value:

Hope this helps.

1 Like

Thanks for the reply. However, I could not proceed because I got the following error
image

I am using 7.17.9 stack.

The now() function has been introduced in 8.9.0 version.