简体   繁体   中英

Is it possible to query a KSQL Table/Materialized view via HTTP?

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?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM