@@ -16,13 +16,17 @@ import json
1616
1717# Define the URL
1818url = "https://${ this . instance } :8080/v1/logs"
19- logs = [] # Replace with your actual log data
20- payload = json.dumps(logs)
19+
20+ # Define the payload (replace this with your actual log data)
21+ payload = json.dumps({
22+ "dataType": "json-input",
23+ "dataSource": "api-gateway",
24+ "raw": "{\\"level\\":\\"error\\",\\"msg\\":\\"connection refused\\",\\"user\\":\\"admin\\",\\"ip\\":\\"10.0.0.5\\",\\"endpoint\\":\\"/api/login\\",\\"status\\":500}"
25+ })
2126
2227# Define headers
2328headers = {
2429 'Utm-Connection-Key': '${ this . mask } ',
25- 'Utm-Log-Source': 'your log source (mandatory header)',
2630 'Content-Type': 'application/json'
2731}
2832
@@ -39,14 +43,13 @@ OkHttpClient client = new OkHttpClient().newBuilder().build();
3943
4044// Define the media type and request body (replace this with your actual request body)
4145MediaType mediaType = MediaType.parse("application/json");
42- RequestBody body = RequestBody.create(mediaType, "[]\\n ");
46+ RequestBody body = RequestBody.create(mediaType, "{\\"dataType\\":\\"json-input\\",\\"dataSource\\":\\"api-gateway\\",\\"raw\\":\\"{\\\\\\"level\\\\\\":\\\\\\"error\\\\\\",\\\\\\"msg\\\\\\":\\\\\\"connection refused\\\\\\",\\\\\\"user\\\\\\":\\\\\\"admin\\\\\\",\\\\\\"ip\\\\\\":\\\\\\"10.0.0.5\\\\\\",\\\\\\"endpoint\\\\\\":\\\\\\"/api/login\\\\\\",\\\\\\"status\\\\\\":500}\\"} ");
4347
4448// Create the request
4549Request request = new Request.Builder()
4650 .url("https://${ this . instance } :8080/v1/logs")
4751 .method("POST", body)
4852 .addHeader("Utm-Connection-Key", "${ this . mask } ")
49- .addHeader("Utm-Log-Source", "your log source (mandatory header)")
5053 .addHeader("Content-Type", "application/json")
5154 .build();
5255
@@ -70,7 +73,7 @@ func main() {
7073 method := "POST"
7174
7275 // Define the payload (replace this with your actual payload)
73- payload := strings.NewReader([] )
76+ payload := strings.NewReader("{\\"dataType\\":\\"json-input\\",\\"dataSource\\":\\"api-gateway\\",\\"raw\\":\\"{\\\\\\"level\\\\\\":\\\\\\"error\\\\\\",\\\\\\"msg\\\\\\":\\\\\\"connection refused\\\\\\",\\\\\\"user\\\\\\":\\\\\\"admin\\\\\\",\\\\\\"ip\\\\\\":\\\\\\"10.0.0.5\\\\\\",\\\\\\"endpoint\\\\\\":\\\\\\"/api/login\\\\\\",\\\\\\"status\\\\\\":500}\\"}" )
7477
7578 // Create an HTTP client
7679 client := &http.Client{}
@@ -85,7 +88,6 @@ func main() {
8588
8689 // Add headers
8790 req.Header.Add("Utm-Connection-Key", "${ this . mask } ")
88- req.Header.Add("Utm-Log-Source", "your log source (mandatory header)")
8991 req.Header.Add("Content-Type", "application/json")
9092
9193 // Send the request
@@ -119,11 +121,14 @@ var options = {
119121 'url': 'https://${ this . instance } :8080/v1/logs',
120122 'headers': {
121123 'Utm-Connection-Key': '${ this . mask } ',
122- 'Utm-Log-Source': 'your log source (mandatory header)',
123124 'Content-Type': 'application/json'
124125 },
125126 // Define the request body (replace this with your actual request body)
126- body: JSON.stringify([])
127+ body: JSON.stringify({
128+ "dataType": "json-input",
129+ "dataSource": "api-gateway",
130+ "raw": "{\\"level\\":\\"error\\",\\"msg\\":\\"connection refused\\",\\"user\\":\\"admin\\",\\"ip\\":\\"10.0.0.5\\",\\"endpoint\\":\\"/api/login\\",\\"status\\":500}"
131+ })
127132};
128133
129134// Send the request
@@ -137,11 +142,16 @@ request(options, function (error, response) {
137142# Define headers
138143$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
139144$headers.Add("Utm-Connection-Key", "${ this . mask } ")
140- $headers.Add("Utm-Log-Source", "your log source (mandatory header)")
141145$headers.Add("Content-Type", "application/json")
142146
143147# Define the request body (replace this with your actual request body)
144- $body = @"[]"@
148+ $body = @"
149+ {
150+ "dataType": "json-input",
151+ "dataSource": "api-gateway",
152+ "raw": "{\\"level\\":\\"error\\",\\"msg\\":\\"connection refused\\",\\"user\\":\\"admin\\",\\"ip\\":\\"10.0.0.5\\",\\"endpoint\\":\\"/api/login\\",\\"status\\":500}"
153+ }
154+ "@
145155
146156# Send the request and capture the response
147157$response = Invoke-RestMethod 'https://${ this . instance } :8080/v1/logs' -Method 'POST' -Headers $headers -Body $body
@@ -153,23 +163,28 @@ $response | ConvertTo-Json
153163 curlCode = `
154164 curl --location --request POST 'https://${ this . instance } :8080/v1/logs' \\
155165 --header 'Utm-Connection-Key: ${ this . mask } ' \\
156- --header 'Utm-Log-Source: your log source (mandatory header)' \\
157166 --header 'Content-Type: application/json' \\
158- --data '[]'
167+ --data '{
168+ "dataType": "json-input",
169+ "dataSource": "api-gateway",
170+ "raw": "{\\"level\\":\\"error\\",\\"msg\\":\\"connection refused\\",\\"user\\":\\"admin\\",\\"ip\\":\\"10.0.0.5\\",\\"endpoint\\":\\"/api/login\\",\\"status\\":500}"
171+ }'
159172 ` ;
160173 token : string ;
161174 view : 'python' | 'java' | 'javascript' | 'golang' | 'bash' | 'powershell' = 'python' ;
162175 exampleCode = `
163- [
164- {
165- "timestamp": "2023-10-11T08:30:15.123Z",
166- "level": "INFO",
167- "message": "Application started successfully.",
168- "component": "Server",
169- "module": "app.js",
170- "source": "MyApp"
171- }
172- ]
176+ {
177+ "dataType": "json-input",
178+ "dataSource": "api-gateway",
179+ "raw": "{
180+ \\"level\\": \\"error\\",
181+ \\"msg\\": \\"connection refused\\",
182+ \\"user\\": \\"admin\\",
183+ \\"ip\\": \\"10.0.0.5\\",
184+ \\"endpoint\\": \\"/api/login\\",
185+ \\"status\\": 500
186+ }"
187+ }
173188 ` ;
174189 responseBody = `{"status": "received"}` ;
175190
0 commit comments