giraffe icon indicating copy to clipboard operation
giraffe copied to clipboard

Single Stat: allow timestamps to be displayed as the stat

Open TCL735 opened this issue 4 years ago • 1 comments

Currently, Single Stat will only render strings or numbers without any interpretation of what they represent. For example, a timestamp in JavaScript is a number that can be interpreted as milliseconds from a certain time.

Proposal: Allow Single Stat to interpret numbers as timestamps and render a time rather than a number.

Here is an example .csv that will not show a timestamp, but rather just a number.

#group,false,false,true,true,true,true,false,false,true
#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string
#default,_result,,,,,,,,
,result,table,_field,_measurement,_start,_stop,_time,_value,url
,,0,traefik_config_last_reload_success,prometheus,2021-11-12T17:31:49.314450792Z,2021-11-12T18:31:49.314450792Z,2021-11-12T18:31:02.720095288Z,2021-11-12T14:43:33Z,https://www.google.com

The output is this but what we really want is a timestamp: Screen Shot 2021-11-13 at 8 13 53 AM

TCL735 avatar Nov 13 '21 00:11 TCL735

This requires updating LatestValueTransform to preserve the column type, passing the column type down as props, and then updating formatStatValue to consider the column type.

TCL735 avatar Nov 13 '21 00:11 TCL735