mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-06 00:09:22 +00:00
fix: added timezone offset for pipeline cron (#6608)
This commit is contained in:
@@ -60,7 +60,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<div
|
||||
data-test="add-alert-name-input"
|
||||
class="alert-name-input o2-input"
|
||||
style="padding-top: 12px;"
|
||||
style="padding-top: 12px"
|
||||
>
|
||||
<q-input
|
||||
v-model="formData.name"
|
||||
@@ -91,9 +91,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@folder-selected="updateActiveFolderId"
|
||||
:activeFolderId="activeFolderId"
|
||||
:style="'height: 30px'"
|
||||
/>
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -506,7 +505,6 @@ import { outlinedInfo } from "@quasar/extras/material-icons-outlined";
|
||||
import useFunctions from "@/composables/useFunctions";
|
||||
import useQuery from "@/composables/useQuery";
|
||||
import searchService from "@/services/search";
|
||||
import { convertDateToTimestamp } from "@/utils/date";
|
||||
|
||||
import SelectFolderDropDown from "../common/sidebar/SelectFolderDropDown.vue";
|
||||
import cronParser from "cron-parser";
|
||||
@@ -562,7 +560,7 @@ const defaultValue: any = () => {
|
||||
updatedAt: "",
|
||||
owner: "",
|
||||
lastEditedBy: "",
|
||||
folder_id : "",
|
||||
folder_id: "",
|
||||
};
|
||||
};
|
||||
let callAlert: Promise<{ data: any }>;
|
||||
@@ -655,8 +653,10 @@ export default defineComponent({
|
||||
const vrlFunctionError = ref("");
|
||||
|
||||
const showTimezoneWarning = ref(false);
|
||||
|
||||
const activeFolderId = ref(router.currentRoute.value.query.folder || "default");
|
||||
|
||||
const activeFolderId = ref(
|
||||
router.currentRoute.value.query.folder || "default",
|
||||
);
|
||||
|
||||
const isAlertSaving = ref(false);
|
||||
|
||||
@@ -1217,8 +1217,8 @@ export default defineComponent({
|
||||
query.query.start_time = query.query.start_time + 780000000;
|
||||
|
||||
query.query.sql = formData.value.query_condition.sql;
|
||||
//removed the encoding as it is not required for the alert queries
|
||||
if(store.state.zoConfig.sql_base64_enabled && query?.encoding){
|
||||
//removed the encoding as it is not required for the alert queries
|
||||
if (store.state.zoConfig.sql_base64_enabled && query?.encoding) {
|
||||
delete query.encoding;
|
||||
}
|
||||
|
||||
@@ -1365,7 +1365,6 @@ export default defineComponent({
|
||||
sqlQueryErrorMsg,
|
||||
vrlFunctionError,
|
||||
updateFunctionVisibility,
|
||||
convertDateToTimestamp,
|
||||
getTimezonesByOffset,
|
||||
showTimezoneWarning,
|
||||
updateMultiTimeRange,
|
||||
@@ -1382,10 +1381,10 @@ export default defineComponent({
|
||||
// TODO OK: Refactor this code
|
||||
this.formData.ingest = ref(false);
|
||||
this.formData = { ...defaultValue, ...cloneDeep(this.modelValue) };
|
||||
if(!this.isUpdated){
|
||||
this.formData.is_real_time = this.alertType === 'realTime'? true : false;
|
||||
if (!this.isUpdated) {
|
||||
this.formData.is_real_time = this.alertType === "realTime" ? true : false;
|
||||
}
|
||||
this.formData.is_real_time = this.formData.is_real_time.toString();
|
||||
this.formData.is_real_time = this.formData.is_real_time.toString();
|
||||
|
||||
// Set default frequency to min_auto_refresh_interval
|
||||
if (this.store.state?.zoConfig?.min_auto_refresh_interval)
|
||||
@@ -1498,30 +1497,9 @@ export default defineComponent({
|
||||
this.formData.is_real_time == "false" &&
|
||||
this.formData.trigger_condition.frequency_type == "cron"
|
||||
) {
|
||||
const now = new Date();
|
||||
|
||||
// Get the day, month, and year from the date object
|
||||
const day = String(now.getDate()).padStart(2, "0");
|
||||
const month = String(now.getMonth() + 1).padStart(2, "0"); // January is 0!
|
||||
const year = now.getFullYear();
|
||||
|
||||
// Combine them in the DD-MM-YYYY format
|
||||
const date = `${day}-${month}-${year}`;
|
||||
|
||||
// Get the hours and minutes, ensuring they are formatted with two digits
|
||||
const hours = String(now.getHours()).padStart(2, "0");
|
||||
const minutes = String(now.getMinutes()).padStart(2, "0");
|
||||
|
||||
// Combine them in the HH:MM format
|
||||
const time = `${hours}:${minutes}`;
|
||||
|
||||
const convertedDateTime = this.convertDateToTimestamp(
|
||||
date,
|
||||
time,
|
||||
this.formData.tz_offset = getTimezoneOffset(
|
||||
this.formData.trigger_condition.timezone,
|
||||
);
|
||||
|
||||
this.formData.tz_offset = convertedDateTime.offset;
|
||||
}
|
||||
|
||||
this.addAlertForm.validate().then(async (valid: any) => {
|
||||
@@ -1561,11 +1539,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
if (this.beingUpdated) {
|
||||
payload.folder_id = this.router.currentRoute.value.query.folder || "default";
|
||||
payload.folder_id =
|
||||
this.router.currentRoute.value.query.folder || "default";
|
||||
callAlert = alertsService.update_by_alert_id(
|
||||
this.store.state.selectedOrganization.identifier,
|
||||
payload,
|
||||
this.activeFolderId
|
||||
this.activeFolderId,
|
||||
);
|
||||
callAlert
|
||||
.then((res: { data: any }) => {
|
||||
@@ -1598,7 +1577,7 @@ export default defineComponent({
|
||||
callAlert = alertsService.create_by_alert_id(
|
||||
this.store.state.selectedOrganization.identifier,
|
||||
payload,
|
||||
this.activeFolderId
|
||||
this.activeFolderId,
|
||||
);
|
||||
|
||||
callAlert
|
||||
|
||||
@@ -42,7 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
v-model:trigger="streamRoute.trigger_condition"
|
||||
v-model:sql="streamRoute.query_condition.sql"
|
||||
v-model:promql="streamRoute.query_condition.promql"
|
||||
v-model:promql_condition="streamRoute.query_condition.promql_condition"
|
||||
v-model:promql_condition="
|
||||
streamRoute.query_condition.promql_condition
|
||||
"
|
||||
v-model:query_type="streamRoute.query_condition.type"
|
||||
v-model:aggregation="streamRoute.query_condition.aggregation"
|
||||
v-model:stream_type="streamRoute.stream_type"
|
||||
@@ -78,7 +80,7 @@ import {
|
||||
onActivated,
|
||||
} from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { getUUID } from "@/utils/zincutils";
|
||||
import { getTimezoneOffset, getUUID } from "@/utils/zincutils";
|
||||
import { useStore } from "vuex";
|
||||
import { useRouter } from "vue-router";
|
||||
import useStreams from "@/composables/useStreams";
|
||||
@@ -251,7 +253,6 @@ const getDefaultStreamRoute: any = () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
if (pipelineObj.isEditNode) {
|
||||
streamRoute.value = pipelineObj.currentSelectedNodeData
|
||||
?.data as StreamRoute;
|
||||
@@ -379,6 +380,7 @@ const saveQueryData = async () => {
|
||||
formData.trigger_condition.period,
|
||||
);
|
||||
}
|
||||
|
||||
let queryPayload: any = {
|
||||
node_type: "query", // required
|
||||
stream_type: formData.stream_type, // required
|
||||
@@ -406,6 +408,12 @@ const saveQueryData = async () => {
|
||||
timezone: formData.trigger_condition.timezone,
|
||||
},
|
||||
};
|
||||
|
||||
if (formData.trigger_condition.frequency_type === "cron") {
|
||||
queryPayload.tz_offset =
|
||||
getTimezoneOffset(formData.trigger_condition.timezone) || 0;
|
||||
}
|
||||
|
||||
if (formData.query_condition.type == "promql") {
|
||||
if (queryPayload?.query_condition) {
|
||||
queryPayload.query_condition.sql = "";
|
||||
@@ -479,8 +487,8 @@ const validateSqlQuery = () => {
|
||||
|
||||
query.query.sql = streamRoute.value.query_condition.sql;
|
||||
|
||||
//removed the encoding as it is not required for the pipeline queries
|
||||
if(store.state.zoConfig.sql_base64_enabled && query?.encoding){
|
||||
//removed the encoding as it is not required for the pipeline queries
|
||||
if (store.state.zoConfig.sql_base64_enabled && query?.encoding) {
|
||||
delete query.encoding;
|
||||
}
|
||||
|
||||
|
||||
@@ -826,7 +826,7 @@ export const durationFormatter = (durationInSeconds: number): string => {
|
||||
return formattedDuration;
|
||||
};
|
||||
|
||||
export const getTimezoneOffset = () => {
|
||||
export const getTimezoneOffset = (timezone: string |null = null) => {
|
||||
const now = new Date();
|
||||
|
||||
// Get the day, month, and year from the date object
|
||||
@@ -844,7 +844,7 @@ export const getTimezoneOffset = () => {
|
||||
// Combine them in the HH:MM format
|
||||
const scheduleTime = `${hours}:${minutes}`;
|
||||
|
||||
const ScheduleTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const ScheduleTimezone = timezone ? timezone : Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
const convertedDateTime = convertDateToTimestamp(
|
||||
scheduleDate,
|
||||
|
||||
Reference in New Issue
Block a user