To setup an Alibaba Cloud SLS binding create a component of type bindings.alicloud.sls
. See this guide on how to create and apply a binding configuration.
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: alicloud.sls
spec:
type: bindings.alicloud.sls
version: v1
metadata:
- name: AccessKeyID
value: "[accessKey-id]"
- name: AccessKeySecret
value: "[accessKey-secret]"
- name: Endpoint
value: "[endpoint]"
Field | Required | Binding support | Details | Example |
---|---|---|---|---|
AccessKeyID | Y | Output | Access key ID credential. | |
AccessKeySecret | Y | Output | Access key credential secret | |
Endpoint | Y | Output | Alicloud SLS endpoint. |
This component supports output binding with the following operations:
create
: Create objectTo perform a log store operation, invoke the binding with a POST
method and the following JSON body:
{
"metadata":{
"project":"your-sls-project-name",
"logstore":"your-sls-logstore-name",
"topic":"your-sls-topic-name",
"source":"your-sls-source"
},
"data":{
"custome-log-filed":"any other log info"
},
"operation":"create"
}
curl -X POST -H "Content-Type: application/json" -d "{\"metadata\":{\"project\":\"project-name\",\"logstore\":\"logstore-name\",\"topic\":\"topic-name\",\"source\":\"source-name\"},\"data\":{\"log-filed\":\"log info\"}" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
curl -X POST -H "Content-Type: application/json" -d '{"metadata":{"project":"project-name","logstore":"logstore-name","topic":"topic-name","source":"source-name"},"data":{"log-filed":"log info"}' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
As Alibaba Cloud SLS producer API is asynchronous, there is no response for this binding (there is no callback interface to accept the response of success or failure, only a record for failure any reason to the console log).