Skip to content

Commit 3c5ae41

Browse files
fix: add output format type for external destination(pipeline destination) (openobserve#6993)
1.This PR adds the output format to the external destination either json / ndjson , bydefault it is json --------- Co-authored-by: oasisk <[email protected]>
1 parent 2db1d49 commit 3c5ae41

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

src/handler/http/models/destinations.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl From<meta_dest::Destination> for Destination {
5858
template: Some(template),
5959
#[cfg(feature = "enterprise")]
6060
action_id: endpoint.action_id,
61+
output_format: endpoint.output_format,
6162
..Default::default()
6263
},
6364
meta_dest::DestinationType::Sns(aws_sns) => Self {
@@ -76,6 +77,7 @@ impl From<meta_dest::Destination> for Destination {
7677
skip_tls_verify: endpoint.skip_tls_verify,
7778
headers: endpoint.headers,
7879
destination_type: DestinationType::Http,
80+
output_format: endpoint.output_format,
7981
..Default::default()
8082
},
8183
}

web/src/components/alerts/AddDestination.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
138138
tabindex="0"
139139
/>
140140
</div>
141-
<div class="col-6 q-py-xs destination-method-select">
141+
<div class="col-3 q-py-xs destination-method-select">
142142
<q-select
143143
data-test="add-destination-method-select"
144144
v-model="formData.method"
@@ -155,6 +155,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
155155
:rules="[(val: any) => !!val || 'Field is required!']"
156156
tabindex="0"
157157
/>
158+
159+
</div>
160+
<div class="col-3 q-py-xs destination-method-select">
161+
<q-select
162+
data-test="add-destination-output-format-select"
163+
v-model="formData.output_format"
164+
:label="t('alert_destinations.output_format') + ' *'"
165+
:options="outputFormats"
166+
color="input-border"
167+
bg-color="input-bg"
168+
class="showLabelOnTop"
169+
stack-label
170+
outlined
171+
:popup-content-style="{ textTransform: 'uppercase' }"
172+
filled
173+
dense
174+
:rules="[(val: any) => !!val || 'Field is required!']"
175+
tabindex="0"
176+
/>
177+
158178
</div>
159179
<div class="col-12 q-py-sm">
160180
<div class="text-bold q-py-xs" style="paddingleft: 10px">
@@ -352,6 +372,7 @@ const props = defineProps({
352372
const emit = defineEmits(["get:destinations", "cancel:hideform"]);
353373
const q = useQuasar();
354374
const apiMethods = ["get", "post", "put"];
375+
const outputFormats = ["json", "ndjson"];
355376
const store = useStore();
356377
const { t } = useI18n();
357378
const formData: Ref<DestinationData> = ref({
@@ -364,6 +385,7 @@ const formData: Ref<DestinationData> = ref({
364385
emails: "",
365386
type: "http",
366387
action_id: "",
388+
output_format: "json",
367389
});
368390
const isUpdatingDestination = ref(false);
369391
@@ -462,6 +484,9 @@ const setupDestinationData = () => {
462484
addApiHeader(key, value);
463485
});
464486
}
487+
if (props.destination.output_format) {
488+
formData.value.output_format = props.destination.output_format;
489+
}
465490
}
466491
};
467492
@@ -543,6 +568,7 @@ const saveDestination = () => {
543568
template: props.isAlerts ? formData.value.template : "",
544569
headers: headers,
545570
name: formData.value.name,
571+
output_format: formData.value.output_format,
546572
};
547573
548574
if (formData.value.type === "email") {

web/src/components/pipeline/NodeForm/ExternalDestination.vue

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
117117
tabindex="0"
118118
/>
119119
</div>
120-
<div
120+
<div class="tw-flex tw-flex-row tw-gap-x-2">
121+
<div
121122
v-if="createNewDestination"
122-
class="col-12 q-py-xs destination-method-select"
123+
class="tw-w-1/2 q-py-xs destination-method-select"
123124
>
124125
<q-select
125126
data-test="add-destination-method-select"
@@ -138,6 +139,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
138139
tabindex="0"
139140
/>
140141
</div>
142+
<div
143+
v-if="createNewDestination"
144+
class="tw-w-1/2 q-py-xs destination-method-select"
145+
>
146+
<q-select
147+
data-test="add-destination-output-format-select"
148+
v-model="formData.output_format"
149+
:label="t('alert_destinations.output_format') + ' *'"
150+
:options="outputFormats"
151+
color="input-border"
152+
bg-color="input-bg"
153+
class="showLabelOnTop "
154+
stack-label
155+
outlined
156+
:popup-content-style="{ textTransform: 'uppercase' }"
157+
filled
158+
dense
159+
:rules="[(val: any) => !!val || 'Field is required!']"
160+
tabindex="0"
161+
/>
162+
</div>
163+
</div>
164+
141165
<div v-if="createNewDestination" class="col-12 q-py-sm">
142166
<div class="text-bold q-py-xs" style="paddingleft: 10px">
143167
Headers
@@ -275,6 +299,7 @@ import useDragAndDrop from "@/plugins/pipelines/useDnD";
275299
const emit = defineEmits(["get:destinations", "cancel:hideform"]);
276300
const q = useQuasar();
277301
const apiMethods = ["get", "post", "put"];
302+
const outputFormats = ["json", "ndjson"];
278303
const store = useStore();
279304
const { t } = useI18n();
280305
const formData: Ref<DestinationData> = ref({
@@ -286,6 +311,7 @@ const formData: Ref<DestinationData> = ref({
286311
headers: {},
287312
emails: "",
288313
type: "http",
314+
output_format: "json",
289315
});
290316
const isUpdatingDestination = ref(false);
291317
const createNewDestination = ref(false);
@@ -334,6 +360,7 @@ watch(
334360
headers: {},
335361
emails: "",
336362
type: "http",
363+
output_format: "json",
337364
};
338365
apiHeaders.value = [{ key: "", value: "", uuid: getUUID() }];
339366
}
@@ -370,6 +397,7 @@ const createDestination = () => {
370397
headers: headers,
371398
name: formData.value.name,
372399
type: "http",
400+
output_format: formData.value.output_format,
373401
};
374402
375403
destinationService

web/src/ts/interfaces/alert.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export interface DestinationPayload {
104104
emails?: string[];
105105
type: "http" | "email" | "sns" | "action";
106106
action_id?: string;
107+
output_format?: "json" | "ndjson";
107108
}
108109

109110
// Destination object which is modified in frontend to display in table and form

0 commit comments

Comments
 (0)