I have a materialized view created using
CREATE TABLE average_latency AS SELECT DEVICENAME, AVG(LATENCY) AS AVG_LATENCY FROM metrics WINDOW TUMBLING (SIZE 1 MINUTE) GROUP BY DEVICENAME EMIT CHANGES;
I would like to query the table average_latency
via a REST API call to get the AVG_LATENCY
and DEVICENAME
column in the response.
HTTP Client -> KSQL Table/Materialized view
Is this use-case possible? If so, how?
It is possible to query the internal state store used by Kafka streams by exposing an RPC endpoint on the streams application. Check out the following documentation and examples provided by Confluent.
You can get the result of the query using http. You have to send a post method with your query to the ksql address
curl -X "POST" "http://localhost:8088/query" \
-H "Accept: application/vnd.ksql.v1+json" \
-d $'{
"ksql": "SELECT * FROM TEST_STREAM EMIT CHANGES;",
"streamsProperties": {}
}'
I took it from the developer guide of ksql https://docs.ksqldb.io/en/latest/developer-guide/api/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.