class="o2-secondary-button tw:h-[36px]"
flat
no-caps
+ @mousedown.prevent
@click="$emit('delete:node')"
>
@@ -1201,6 +1203,7 @@ size="md" />
:label="t('alerts.cancel')"
flat
no-caps
+ @mousedown.prevent
@click="$emit('cancel:form')"
/>
"
class="no-border q-ml-md o2-primary-button tw:h-[36px]"
no-caps
+ @mousedown.prevent
@click.prevent="$emit('submit:form')"
:disable="validatingSqlQuery"
/>
@@ -1414,13 +1418,13 @@ const { t } = useI18n();
const triggerData = ref(props.trigger);
-const query = ref(props.sql);
+const tab = ref(props.query_type || "custom");
+
+const query = ref(tab.value === "promql" ? props.promql : props.sql);
const promqlQuery = ref(props.promql);
const delayCondition = ref(props.delay);
-
-const tab = ref(props.query_type || "custom");
const stream_type = ref(props.streamType || "logs");
const collapseFields = ref(false);
@@ -1559,6 +1563,14 @@ onMounted(async () => {
selectedStreamName.value = parsedQuery?.ast.from[0].table;
getStreamFields();
+ } else if (tab.value === "promql" && query.value != "") {
+ // Extract stream name from PromQL query
+ // PromQL query format: stream_name{} or stream_name{label="value"}
+ const match = query.value.match(/^([a-zA-Z0-9_-]+)/);
+ if (match) {
+ selectedStreamName.value = match[1];
+ getStreamFields();
+ }
}
}, 200);
@@ -2201,7 +2213,7 @@ const updateDateChange = (date: any) => {
const runQuery = async () => {
notificationMsgValue.value = "";
- //check if datetime is present or not
+ //check if datetime is present or not
//else show the error message
if(!dateTime.value.startTime) {
notificationMsgValue.value = "The selected start time is invalid. Please choose a valid time.";
@@ -2250,7 +2262,11 @@ const runQuery = async () => {
loading.value = false;
});
} else if (tab.value == "promql") {
- previewPromqlQueryRef.value.refreshData();
+ // Wait for next tick to ensure PreviewPromqlQuery component is mounted
+ await nextTick();
+ if (previewPromqlQueryRef.value) {
+ previewPromqlQueryRef.value.refreshData();
+ }
}
};