In my VOLTTRON agent I am making some calculations and then publishing some float data to the VOLTTRON message bus where then the forward agent should pick it up and SQL agent ingest the data into the time scale SQL.
Can someone help me with if I publish to the bus with this in my agent code:
#publish to message bus
self.vip.pubsub.publish(
peer="pubsub",
topic=
f"LBS_AGENT",
headers={headers.TIMESTAMP: format_timestamp(get_aware_utc_now())},
message=f"TOTAL_AIR_FLOW/{total_flow_temp}",
)
How would I query for it in Grafana? This doesn't work:
SELECT
"time" AS "time",
metric AS metric,
value
FROM slipstream_volttron
WHERE
$__timeFilter("time") AND
metric LIKE 'TOTAL_AIR_FLOW'
ORDER BY 1,2
The way I do it is:
SELECT * FROM topics WHERE topic_name LIKE ('%fake%');
You will see something like
1 | campus/building/fake/OutsideAirTemperature1 | {"units": "F", "type": "integer", "tz": "US/Pacific"} 2 | campus/building/fake/SampleLong1 | {"units": "Enumeration", "type": "integer", "tz": "US/Pacific"} 3 | campus/building/fake/SampleBool1 | {"units": "On / Off", "type": "integer", "tz": "US/Pacific"} 4 | campus/building/fake/OutsideAirTemperature2 | {"units": "F", "type": "integer", "tz": "US/Pacific"} 5 | campus/building/fake/SampleLong2 | {"units": "Enumeration", "type": "integer", "tz": "US/Pacific"} 6 | campus/building/fake/SampleBool2 | {"units": "On / Off", "type": "integer", "tz": "US/Pacific"}
Let say you are interested in campus/building/fake/SampleLong2
Then Grafana would be:
SELECT
$__time(data.ts),
CAST (data.value_string AS DECIMAL) as "Label"
FROM data, topics
WHERE
$__timeFilter(ts) AND
data.topic_id = topics.topic_id AND
topics.topic_name LIKE ('campus/building/fake/SampleLong2')
ORDER BY 1,2
This will work for a Postgres db.