Skip to content

Commit 7a0d15c

Browse files
fix[frontend](integrations/json):updated json input guide
1 parent 823ce46 commit 7a0d15c

3 files changed

Lines changed: 40 additions & 30 deletions

File tree

frontend/e2e/protractor.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports.config = {
1212
'browserName': 'chrome'
1313
},
1414
directConnect: true,
15-
baseUrl: 'http://localhost:4200/',
15+
baseUrl: 'https://192.168.1.18:8080/',
1616
framework: 'jasmine',
1717
jasmineNodeOpts: {
1818
showColors: true,

frontend/src/app/app-module/guides/guide-json/guide-json.component.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ <h4 class="card-title mb-0 text-primary">
2020
<span class="header-name"><span class="text-danger-300">*</span> Utm-Connection-Key:</span>
2121
<span class="header-value">{{mask}}</span>
2222
</div>
23-
<div class="request-header-item">
24-
<span class="header-name"><span class="text-danger-300">*</span> Utm-Log-Source:</span>
25-
<span class="header-value">your log source (mandatory header)</span>
26-
</div>
2723
<div class="request-header-item">
2824
<span class="header-name"><span class="text-danger-300">*</span> Content-Type:</span>
2925
<span class="header-value">application/json</span>
3026
</div>
3127
</div>
3228
<div class="request-body">
33-
<h6 class="font-weight-semibold mb-2">Body (any valid object array)</h6>
29+
<h6 class="font-weight-semibold mb-2">Body</h6>
3430
<label class="font-weight-semibold mb-2">Body Example: </label>
3531
<code>{{exampleCode}}</code>
3632
</div>
@@ -60,7 +56,6 @@ <h6 class="font-weight-semibold mb-2">Errors</h6>
6056
<div class="error-description ml-2">
6157
<ul class="">
6258
<li>- Header Utm-Connection-Key not found</li>
63-
<li>- Header Utm-Log-Source not found</li>
6459
<li>- Invalid body</li>
6560
</ul>
6661
</div>

frontend/src/app/app-module/guides/guide-json/guide-json.component.ts

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ import json
1616
1717
# Define the URL
1818
url = "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
2328
headers = {
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)
4145
MediaType 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
4549
Request 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

Comments
 (0)