Skip to content

Commit 84745ee

Browse files
Adds logpush destination (#19960)
1 parent bf9f60f commit 84745ee

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: Enable IBM Cloud Logs
3+
pcx_content_type: how-to
4+
sidebar:
5+
order: 99
6+
head:
7+
- tag: title
8+
content: Enable Logpush IBM Cloud Logs
9+
10+
---
11+
12+
Cloudflare Logpush supports pushing logs directly to IBM Cloud Logs via API. The dashboard functionality will later be added.
13+
14+
## Manage via API
15+
16+
To set up an IBM Cloud Logs job:
17+
18+
1. Create a job with the appropriate endpoint URL and authentication parameters.
19+
2. Enable the job to begin pushing logs.
20+
21+
:::note[Note]
22+
Ensure Log Share permissions are enabled, before attempting to read or configure a Logpush job. For more information refer to the [Roles section](/logs/get-started/permissions/#roles).
23+
:::
24+
25+
### 1. Create a job
26+
27+
To create a job, make a `POST` request to the Logpush jobs endpoint with the following fields:
28+
29+
- **name** (optional) - Use your domain name as the job name.
30+
- **output_options** (optional) - This parameter is used to define the desired output format and structure. Below are the configurable fields:
31+
- output_type
32+
- timestamp_format
33+
- batch_prefix and batch_suffix
34+
- record_prefix and record_suffix
35+
- record_delimiter
36+
- **destination_conf** - A log destination consisting of Instance ID, Region and [IBM API Key](https://cloud.ibm.com/docs/account?topic=account-iamtoken_from_apikey) in the string format below.
37+
38+
`ibmcl://<INSTANCE_ID>.ingress.<REGION>.logs.cloud.ibm.com/logs/v1/singles?ibm_api_key=<IBM_API_KEY>`
39+
40+
- **max_upload_records** (optional) - The maximum number of log lines per batch. This must be at least 1,000 lines or more. Note that there is no way to specify a minimum number of log lines per batch. This means that log files may contain many fewer lines than specified.
41+
- **max_upload_bytes** (optional) - The maximum uncompressed file size for a batch of logs. We recommend a default value of 2 MB per upload based on IBM's limits, which our system will enforce for this destination. Since minimum file sizes cannot be set, log files may be smaller than the specified batch size.
42+
- **dataset** - The category of logs you want to receive. Refer to [Log fields](/logs/reference/log-fields/) for the full list of supported datasets.
43+
44+
Example request using cURL:
45+
46+
```bash
47+
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/logpush/jobs \
48+
--header "X-Auth-Email: <EMAIL>" \
49+
--header "X-Auth-Key: <API_KEY>" \
50+
--header "Content-Type: application/json" \
51+
--data '{
52+
"name": "<DOMAIN_NAME>",
53+
"output_options": {
54+
"output_type": "ndjson",
55+
"timestamp_format": "rfc3339",
56+
"batch_prefix": "[",
57+
"batch_suffix": "]",
58+
"record_prefix": "{\"applicationName\":\"ibm-platform-log\",\"subsystemName\":\"internet-svcs:logpush\",\"text\":{",
59+
"record_suffix": "}}",
60+
"record_delimiter": ","
61+
},
62+
"destination_conf": "ibmcl://<INSTANCE_ID>.ingress.<REGION>.logs.cloud.ibm.com/logs/v1/singles?ibm_api_key=<IBM_API_KEY>",
63+
"max_upload_bytes": 2000000,
64+
"dataset": "http_requests",
65+
"enabled": true
66+
}'
67+
```
68+
69+
Response:
70+
71+
```json
72+
{
73+
"errors": [],
74+
"messages": [],
75+
"result": {
76+
"dataset": "http_requests",
77+
"destination_conf": "ibmcl://<INSTANCE_ID>.ingress.<REGION>.logs.cloud.ibm.com/logs/v1/singles?ibm_api_key=<IBM_API_KEY>",
78+
"enabled": true,
79+
"error_message": null,
80+
"id": <JOB_ID>,
81+
"kind": "",
82+
"last_complete": null,
83+
"last_error": null,
84+
"output_options": {
85+
"output_type": "ndjson",
86+
"timestamp_format": "rfc3339",
87+
"batch_prefix": "[",
88+
"batch_suffix": "]",
89+
"record_prefix": "{\"applicationName\":\"ibm-platform-log\",\"subsystemName\":\"internet-svcs:logpush\",\"text\":{",
90+
"record_suffix": "}}",
91+
"record_delimiter": ","
92+
},
93+
"logstream": true,
94+
"max_upload_bytes": 2000000,
95+
"name": "<DOMAIN_NAME>"
96+
},
97+
"success": true
98+
}
99+
```
100+
101+
### 2. Enable (update) a job
102+
103+
To enable a job, make a `PUT` request to the Logpush jobs endpoint. You will use the job ID returned from the previous step in the URL and send `{"enabled": true}` in the request body.
104+
105+
Example request using cURL:
106+
107+
```bash
108+
curl --request PUT \
109+
https://api.cloudflare.com/client/v4/zones/{zone_id}/logpush/jobs/{job_id} \
110+
--header "X-Auth-Email: <EMAIL>" \
111+
--header "X-Auth-Key: <API_KEY>" \
112+
--header "Content-Type: application/json" \
113+
--data '{
114+
"enabled": true
115+
}'
116+
```
117+
118+
Response:
119+
120+
```json
121+
{
122+
"errors": [],
123+
"messages": [],
124+
"result": {
125+
"dataset": "http_requests",
126+
"destination_conf": "ibmcl://<INSTANCE_ID>.ingress.<REGION>.logs.cloud.ibm.com/logs/v1/singles?ibm_api_key=<IBM_API_KEY>",
127+
"enabled": true,
128+
"error_message": null,
129+
"id": <JOB_ID>,
130+
"kind": "",
131+
"last_complete": null,
132+
"last_error": null,
133+
"output_options": {
134+
"output_type": "ndjson",
135+
"timestamp_format": "rfc3339",
136+
"batch_prefix": "[",
137+
"batch_suffix": "]",
138+
"record_prefix": "{\"applicationName\":\"ibm-platform-log\",\"subsystemName\":\"internet-svcs:logpush\",\"text\":{",
139+
"record_suffix": "}}",
140+
"record_delimiter": ","
141+
},
142+
"logstream": true,
143+
"max_upload_bytes": 2000000,
144+
"name": "<DOMAIN_NAME>"
145+
},
146+
"success": true
147+
}
148+
```

0 commit comments

Comments
 (0)