Grafana: выделения времени суток на шкале TimeScale
В одном из проектов (умный дом) у меня мониторится температура окружающего воздуха. Но график… ну так себе если честно..
Ну совершенно не понятно не поёрзав мышкой, где день, где ночь.. Решил неказисто,.. но хотя бы уже понятно:
Просто наложив поверх еще один запрос, где вывожу в зависимости от часа суток предопределенные значения.
1 |
<div style="color: #000000;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #0000ff;">SELECT</span><span style="color: #000000;"> </span></div><div><span style="color: #000000;"> </span><span style="color: #008080;">$__time</span><span style="color: #000000;">(m_data.dt),</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">CASE</span><span style="color: #000000;"> </span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">WHEN</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)>=21 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)<=23 </span><span style="color: #0000ff;">THEN</span><span style="color: #000000;"> -</span><span style="color: #098658;">35</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">WHEN</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)>=0 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)<=2 </span><span style="color: #0000ff;">THEN</span><span style="color: #000000;"> -</span><span style="color: #098658;">35</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">WHEN</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)>=3 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)<=8 </span><span style="color: #0000ff;">THEN</span><span style="color: #000000;"> -</span><span style="color: #098658;">17</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">WHEN</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)>=9 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)<=14 </span><span style="color: #0000ff;">THEN</span><span style="color: #000000;"> </span><span style="color: #098658;">35</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">WHEN</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)>=15 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #0000ff;">hour</span><span style="color: #000000;">(dt)<=20 </span><span style="color: #0000ff;">THEN</span><span style="color: #000000;"> </span><span style="color: #098658;">17</span></div><div><span style="color: #000000;"> </span><span style="color: #0000ff;">END</span><span style="color: #000000;"> </span><span style="color: #0000ff;">as</span><span style="color: #000000;"> </span><span style="color: #ff0000;">'Время суток'</span></div><div><span style="color: #0000ff;">FROM</span><span style="color: #000000;"> </span></div><div><span style="color: #000000;"> m_data.m_data </span></div><div><span style="color: #0000ff;">WHERE</span><span style="color: #000000;"> </span></div><div><span style="color: #000000;"> m_data.place=10 </span><span style="color: #778899;">and</span><span style="color: #000000;"> m_data.source=17 </span><span style="color: #778899;">and</span><span style="color: #000000;"> m_data.value_type=1 </span><span style="color: #778899;">and</span><span style="color: #000000;"> </span><span style="color: #008080;">$__timeFilter</span><span style="color: #000000;">(m_data.dt) </span></div></div> |