aliyun-timestream allows you to use the InfluxDB line protocol to synchronize data from InfluxDB to time series indexes in Elasticsearch. This topic describes the API that can be used to synchronize data from InfluxDB to time series indexes in Elasticsearch. This topic also describes the usage notes of the API and provides usage examples.
Prerequisites
An Elasticsearch V7.10 cluster of the Standard Edition is created. The kernel version of the cluster is V1.8.0 or later. For more information, see Create an Alibaba Cloud Elasticsearch cluster.
Request syntax
POST /_time_stream/influx/write?db={index}&precision=ns
{infludb lines data}
Request parameters
Parameter | Description |
db | Required. This parameter specifies the name of the time series index to which you want to write data. |
precision | Optional. The precision parameter. Valid values: n, ns, u, ms, s, m, and h. If you do not configure this parameter, the default value ns is used. |
Usage notes
// Syntax
<measurement>[,<tag_key>=<tag_value>[,<tag_key>=<tag_value>]] <field_key>=<field_value>[,<field_key>=<field_value>] [<timestamp>]
// Example
myMeasurement,tag1=value1,tag2=value2 fieldKey="fieldValue" 1556813561098000000
- Data in InfluxDB
testInflux,label1=label_value1 metric1=0.5
- Data that is written to Elasticsearch
{ "@timestamp": 1669972652000, "labels": { "measurement": "testInflux", "label1": "label_value1" }, "metrics": { "metric1": 0.5 } }
You can use the search APIs of open source Elasticsearch or Prometheus APIs that are integrated with aliyun-timestream to query the data that is synchronized from InfluxDB to Elasticsearch by using the InfluxDB line protocol.
Examples
Sample request
curl -i --user "user:password" "http://xxx:9200/_time_stream/influx/write?db=test_stream" -d "testInflux,label1=label_value1 metric1=0.5"
Sample response
HTTP/1.1 204 No Content
If the data is successfully written to Elasticsearch, the body of the response is displayed as No Content, and the HTTP status code 204 is returned. If the data fails to be written to Elasticsearch, the response is the same as the response returned when data fails to be written by using the InfluxDB write API.