Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: added the support of y axis unit and threshold unit in the alerts page (#3268)

Palash Guptac37d6c3785d6
diff --git a/frontend/public/locales/en-GB/alerts.json b/frontend/public/locales/en-GB/alerts.json
index b5c769a021..816b71e563 100644
--- a/frontend/public/locales/en-GB/alerts.json
+++ b/frontend/public/locales/en-GB/alerts.json
@@ -1,112 +1,113 @@
{
- "target_missing": "Please enter a threshold to proceed",
- "rule_test_fired": "Test notification sent successfully",
- "no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
- "button_testrule": "Test Notification",
- "label_channel_select": "Notification Channels",
- "placeholder_channel_select": "select one or more channels",
- "channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
- "preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
- "preview_chart_threshold_label": "Threshold",
- "placeholder_label_key_pair": "Click here to enter a label (key value pairs)",
- "button_yes": "Yes",
- "button_no": "No",
- "remove_label_confirm": "This action will remove all the labels. Do you want to proceed?",
- "remove_label_success": "Labels cleared",
- "alert_form_step1": "Step 1 - Define the metric",
- "alert_form_step2": "Step 2 - Define Alert Conditions",
- "alert_form_step3": "Step 3 - Alert Configuration",
- "metric_query_max_limit": "Can not create query. You can create maximum of 5 queries",
- "confirm_save_title": "Save Changes",
- "confirm_save_content_part1": "Your alert built with",
- "confirm_save_content_part2": "query will be saved. Press OK to confirm.",
- "unexpected_error": "Sorry, an unexpected error occurred. Please contact your admin",
- "rule_created": "Rule created successfully",
- "rule_edited": "Rule edited successfully",
- "expression_missing": "expression is missing in {{where}}",
- "metricname_missing": "metric name is missing in {{where}}",
- "condition_required": "at least one metric condition is required",
- "alertname_required": "alert name is required",
- "promql_required": "promql expression is required when query format is set to PromQL",
- "chquery_required": "query is required when query format is set to ClickHouse",
- "button_savechanges": "Save Rule",
- "button_createrule": "Create Rule",
- "button_returntorules": "Return to rules",
- "button_cancelchanges": "Cancel",
- "button_discard": "Discard",
- "text_condition1": "Send a notification when the metric is",
- "text_condition2": "the threshold",
- "text_condition3": "during the last",
- "option_5min": "5 mins",
- "option_10min": "10 mins",
- "option_15min": "15 mins",
- "option_60min": "60 mins",
- "option_4hours": "4 hours",
- "option_24hours": "24 hours",
- "field_threshold": "Alert Threshold",
- "option_allthetimes": "all the times",
- "option_atleastonce": "at least once",
- "option_onaverage": "on average",
- "option_intotal": "in total",
- "option_above": "above",
- "option_below": "below",
- "option_equal": "is equal to",
- "option_notequal": "not equal to",
- "button_query": "Query",
- "button_formula": "Formula",
- "tab_qb": "Query Builder",
- "tab_promql": "PromQL",
- "tab_chquery": "ClickHouse Query",
- "title_confirm": "Confirm",
- "button_ok": "Yes",
- "button_cancel": "No",
- "field_promql_expr": "PromQL Expression",
- "field_alert_name": "Alert Name",
- "field_alert_desc": "Alert Description",
- "field_labels": "Labels",
- "field_severity": "Severity",
- "option_critical": "Critical",
- "option_error": "Error",
- "option_warning": "Warning",
- "option_info": "Info",
- "user_guide_headline": "Steps to create an Alert",
- "user_guide_qb_step1": "Step 1 - Define the metric",
- "user_guide_qb_step1a": "Choose a metric which you want to create an alert on",
- "user_guide_qb_step1b": "Filter it based on WHERE field or GROUPBY if needed",
- "user_guide_qb_step1c": "Apply an aggregatiion function like COUNT, SUM, etc. or choose NOOP to plot the raw metric",
- "user_guide_qb_step1d": "Create a formula based on Queries if needed",
- "user_guide_qb_step2": "Step 2 - Define Alert Conditions",
- "user_guide_qb_step2a": "Select the evaluation interval, threshold type and whether you want to alert above/below a value",
- "user_guide_qb_step2b": "Enter the Alert threshold",
- "user_guide_qb_step3": "Step 3 -Alert Configuration",
- "user_guide_qb_step3a": "Set alert severity, name and descriptions",
- "user_guide_qb_step3b": "Add tags to the alert in the Label field if needed",
- "user_guide_pql_step1": "Step 1 - Define the metric",
- "user_guide_pql_step1a": "Write a PromQL query for the metric",
- "user_guide_pql_step1b": "Format the legends based on labels you want to highlight",
- "user_guide_pql_step2": "Step 2 - Define Alert Conditions",
- "user_guide_pql_step2a": "Select the threshold type and whether you want to alert above/below a value",
- "user_guide_pql_step2b": "Enter the Alert threshold",
- "user_guide_pql_step3": "Step 3 -Alert Configuration",
- "user_guide_pql_step3a": "Set alert severity, name and descriptions",
- "user_guide_pql_step3b": "Add tags to the alert in the Label field if needed",
- "user_guide_ch_step1": "Step 1 - Define the metric",
- "user_guide_ch_step1a": "Write a Clickhouse query for alert evaluation. Follow <0>this tutorial</0> to learn about query format and supported vars.",
- "user_guide_ch_step1b": "Format the legends based on labels you want to highlight in the preview chart",
- "user_guide_ch_step2": "Step 2 - Define Alert Conditions",
- "user_guide_ch_step2a": "Select the threshold type and whether you want to alert above/below a value",
- "user_guide_ch_step2b": "Enter the Alert threshold",
- "user_guide_ch_step3": "Step 3 -Alert Configuration",
- "user_guide_ch_step3a": "Set alert severity, name and descriptions",
- "user_guide_ch_step3b": "Add tags to the alert in the Label field if needed",
- "user_tooltip_more_help": "More details on how to create alerts",
- "choose_alert_type": "Choose a type for the alert:",
- "metric_based_alert": "Metric based Alert",
- "metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
- "log_based_alert": "Log-based Alert",
- "log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
- "traces_based_alert": "Trace-based Alert",
- "traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
- "exceptions_based_alert": "Exceptions-based Alert",
- "exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data."
-}
\ No newline at end of file
+ "target_missing": "Please enter a threshold to proceed",
+ "rule_test_fired": "Test notification sent successfully",
+ "no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
+ "button_testrule": "Test Notification",
+ "label_channel_select": "Notification Channels",
+ "placeholder_channel_select": "select one or more channels",
+ "channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
+ "preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
+ "preview_chart_threshold_label": "Threshold",
+ "placeholder_label_key_pair": "Click here to enter a label (key value pairs)",
+ "button_yes": "Yes",
+ "button_no": "No",
+ "remove_label_confirm": "This action will remove all the labels. Do you want to proceed?",
+ "remove_label_success": "Labels cleared",
+ "alert_form_step1": "Step 1 - Define the metric",
+ "alert_form_step2": "Step 2 - Define Alert Conditions",
+ "alert_form_step3": "Step 3 - Alert Configuration",
+ "metric_query_max_limit": "Can not create query. You can create maximum of 5 queries",
+ "confirm_save_title": "Save Changes",
+ "confirm_save_content_part1": "Your alert built with",
+ "confirm_save_content_part2": "query will be saved. Press OK to confirm.",
+ "unexpected_error": "Sorry, an unexpected error occurred. Please contact your admin",
+ "rule_created": "Rule created successfully",
+ "rule_edited": "Rule edited successfully",
+ "expression_missing": "expression is missing in {{where}}",
+ "metricname_missing": "metric name is missing in {{where}}",
+ "condition_required": "at least one metric condition is required",
+ "alertname_required": "alert name is required",
+ "promql_required": "promql expression is required when query format is set to PromQL",
+ "chquery_required": "query is required when query format is set to ClickHouse",
+ "button_savechanges": "Save Rule",
+ "button_createrule": "Create Rule",
+ "button_returntorules": "Return to rules",
+ "button_cancelchanges": "Cancel",
+ "button_discard": "Discard",
+ "text_condition1": "Send a notification when the metric is",
+ "text_condition2": "the threshold",
+ "text_condition3": "during the last",
+ "option_5min": "5 mins",
+ "option_10min": "10 mins",
+ "option_15min": "15 mins",
+ "option_60min": "60 mins",
+ "option_4hours": "4 hours",
+ "option_24hours": "24 hours",
+ "field_threshold": "Alert Threshold",
+ "option_allthetimes": "all the times",
+ "option_atleastonce": "at least once",
+ "option_onaverage": "on average",
+ "option_intotal": "in total",
+ "option_above": "above",
+ "option_below": "below",
+ "option_equal": "is equal to",
+ "option_notequal": "not equal to",
+ "button_query": "Query",
+ "button_formula": "Formula",
+ "tab_qb": "Query Builder",
+ "tab_promql": "PromQL",
+ "tab_chquery": "ClickHouse Query",
+ "title_confirm": "Confirm",
+ "button_ok": "Yes",
+ "button_cancel": "No",
+ "field_promql_expr": "PromQL Expression",
+ "field_alert_name": "Alert Name",
+ "field_alert_desc": "Alert Description",
+ "field_labels": "Labels",
+ "field_severity": "Severity",
+ "option_critical": "Critical",
+ "option_error": "Error",
+ "option_warning": "Warning",
+ "option_info": "Info",
+ "user_guide_headline": "Steps to create an Alert",
+ "user_guide_qb_step1": "Step 1 - Define the metric",
+ "user_guide_qb_step1a": "Choose a metric which you want to create an alert on",
+ "user_guide_qb_step1b": "Filter it based on WHERE field or GROUPBY if needed",
+ "user_guide_qb_step1c": "Apply an aggregatiion function like COUNT, SUM, etc. or choose NOOP to plot the raw metric",
+ "user_guide_qb_step1d": "Create a formula based on Queries if needed",
+ "user_guide_qb_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_qb_step2a": "Select the evaluation interval, threshold type and whether you want to alert above/below a value",
+ "user_guide_qb_step2b": "Enter the Alert threshold",
+ "user_guide_qb_step3": "Step 3 -Alert Configuration",
+ "user_guide_qb_step3a": "Set alert severity, name and descriptions",
+ "user_guide_qb_step3b": "Add tags to the alert in the Label field if needed",
+ "user_guide_pql_step1": "Step 1 - Define the metric",
+ "user_guide_pql_step1a": "Write a PromQL query for the metric",
+ "user_guide_pql_step1b": "Format the legends based on labels you want to highlight",
+ "user_guide_pql_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_pql_step2a": "Select the threshold type and whether you want to alert above/below a value",
+ "user_guide_pql_step2b": "Enter the Alert threshold",
+ "user_guide_pql_step3": "Step 3 -Alert Configuration",
+ "user_guide_pql_step3a": "Set alert severity, name and descriptions",
+ "user_guide_pql_step3b": "Add tags to the alert in the Label field if needed",
+ "user_guide_ch_step1": "Step 1 - Define the metric",
+ "user_guide_ch_step1a": "Write a Clickhouse query for alert evaluation. Follow <0>this tutorial</0> to learn about query format and supported vars.",
+ "user_guide_ch_step1b": "Format the legends based on labels you want to highlight in the preview chart",
+ "user_guide_ch_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_ch_step2a": "Select the threshold type and whether you want to alert above/below a value",
+ "user_guide_ch_step2b": "Enter the Alert threshold",
+ "user_guide_ch_step3": "Step 3 -Alert Configuration",
+ "user_guide_ch_step3a": "Set alert severity, name and descriptions",
+ "user_guide_ch_step3b": "Add tags to the alert in the Label field if needed",
+ "user_tooltip_more_help": "More details on how to create alerts",
+ "choose_alert_type": "Choose a type for the alert:",
+ "metric_based_alert": "Metric based Alert",
+ "metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
+ "log_based_alert": "Log-based Alert",
+ "log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
+ "traces_based_alert": "Trace-based Alert",
+ "traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
+ "exceptions_based_alert": "Exceptions-based Alert",
+ "exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data.",
+ "field_unit": "Threshold unit"
+}
diff --git a/frontend/public/locales/en/alerts.json b/frontend/public/locales/en/alerts.json
index b5c769a021..816b71e563 100644
--- a/frontend/public/locales/en/alerts.json
+++ b/frontend/public/locales/en/alerts.json
@@ -1,112 +1,113 @@
{
- "target_missing": "Please enter a threshold to proceed",
- "rule_test_fired": "Test notification sent successfully",
- "no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
- "button_testrule": "Test Notification",
- "label_channel_select": "Notification Channels",
- "placeholder_channel_select": "select one or more channels",
- "channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
- "preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
- "preview_chart_threshold_label": "Threshold",
- "placeholder_label_key_pair": "Click here to enter a label (key value pairs)",
- "button_yes": "Yes",
- "button_no": "No",
- "remove_label_confirm": "This action will remove all the labels. Do you want to proceed?",
- "remove_label_success": "Labels cleared",
- "alert_form_step1": "Step 1 - Define the metric",
- "alert_form_step2": "Step 2 - Define Alert Conditions",
- "alert_form_step3": "Step 3 - Alert Configuration",
- "metric_query_max_limit": "Can not create query. You can create maximum of 5 queries",
- "confirm_save_title": "Save Changes",
- "confirm_save_content_part1": "Your alert built with",
- "confirm_save_content_part2": "query will be saved. Press OK to confirm.",
- "unexpected_error": "Sorry, an unexpected error occurred. Please contact your admin",
- "rule_created": "Rule created successfully",
- "rule_edited": "Rule edited successfully",
- "expression_missing": "expression is missing in {{where}}",
- "metricname_missing": "metric name is missing in {{where}}",
- "condition_required": "at least one metric condition is required",
- "alertname_required": "alert name is required",
- "promql_required": "promql expression is required when query format is set to PromQL",
- "chquery_required": "query is required when query format is set to ClickHouse",
- "button_savechanges": "Save Rule",
- "button_createrule": "Create Rule",
- "button_returntorules": "Return to rules",
- "button_cancelchanges": "Cancel",
- "button_discard": "Discard",
- "text_condition1": "Send a notification when the metric is",
- "text_condition2": "the threshold",
- "text_condition3": "during the last",
- "option_5min": "5 mins",
- "option_10min": "10 mins",
- "option_15min": "15 mins",
- "option_60min": "60 mins",
- "option_4hours": "4 hours",
- "option_24hours": "24 hours",
- "field_threshold": "Alert Threshold",
- "option_allthetimes": "all the times",
- "option_atleastonce": "at least once",
- "option_onaverage": "on average",
- "option_intotal": "in total",
- "option_above": "above",
- "option_below": "below",
- "option_equal": "is equal to",
- "option_notequal": "not equal to",
- "button_query": "Query",
- "button_formula": "Formula",
- "tab_qb": "Query Builder",
- "tab_promql": "PromQL",
- "tab_chquery": "ClickHouse Query",
- "title_confirm": "Confirm",
- "button_ok": "Yes",
- "button_cancel": "No",
- "field_promql_expr": "PromQL Expression",
- "field_alert_name": "Alert Name",
- "field_alert_desc": "Alert Description",
- "field_labels": "Labels",
- "field_severity": "Severity",
- "option_critical": "Critical",
- "option_error": "Error",
- "option_warning": "Warning",
- "option_info": "Info",
- "user_guide_headline": "Steps to create an Alert",
- "user_guide_qb_step1": "Step 1 - Define the metric",
- "user_guide_qb_step1a": "Choose a metric which you want to create an alert on",
- "user_guide_qb_step1b": "Filter it based on WHERE field or GROUPBY if needed",
- "user_guide_qb_step1c": "Apply an aggregatiion function like COUNT, SUM, etc. or choose NOOP to plot the raw metric",
- "user_guide_qb_step1d": "Create a formula based on Queries if needed",
- "user_guide_qb_step2": "Step 2 - Define Alert Conditions",
- "user_guide_qb_step2a": "Select the evaluation interval, threshold type and whether you want to alert above/below a value",
- "user_guide_qb_step2b": "Enter the Alert threshold",
- "user_guide_qb_step3": "Step 3 -Alert Configuration",
- "user_guide_qb_step3a": "Set alert severity, name and descriptions",
- "user_guide_qb_step3b": "Add tags to the alert in the Label field if needed",
- "user_guide_pql_step1": "Step 1 - Define the metric",
- "user_guide_pql_step1a": "Write a PromQL query for the metric",
- "user_guide_pql_step1b": "Format the legends based on labels you want to highlight",
- "user_guide_pql_step2": "Step 2 - Define Alert Conditions",
- "user_guide_pql_step2a": "Select the threshold type and whether you want to alert above/below a value",
- "user_guide_pql_step2b": "Enter the Alert threshold",
- "user_guide_pql_step3": "Step 3 -Alert Configuration",
- "user_guide_pql_step3a": "Set alert severity, name and descriptions",
- "user_guide_pql_step3b": "Add tags to the alert in the Label field if needed",
- "user_guide_ch_step1": "Step 1 - Define the metric",
- "user_guide_ch_step1a": "Write a Clickhouse query for alert evaluation. Follow <0>this tutorial</0> to learn about query format and supported vars.",
- "user_guide_ch_step1b": "Format the legends based on labels you want to highlight in the preview chart",
- "user_guide_ch_step2": "Step 2 - Define Alert Conditions",
- "user_guide_ch_step2a": "Select the threshold type and whether you want to alert above/below a value",
- "user_guide_ch_step2b": "Enter the Alert threshold",
- "user_guide_ch_step3": "Step 3 -Alert Configuration",
- "user_guide_ch_step3a": "Set alert severity, name and descriptions",
- "user_guide_ch_step3b": "Add tags to the alert in the Label field if needed",
- "user_tooltip_more_help": "More details on how to create alerts",
- "choose_alert_type": "Choose a type for the alert:",
- "metric_based_alert": "Metric based Alert",
- "metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
- "log_based_alert": "Log-based Alert",
- "log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
- "traces_based_alert": "Trace-based Alert",
- "traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
- "exceptions_based_alert": "Exceptions-based Alert",
- "exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data."
-}
\ No newline at end of file
+ "target_missing": "Please enter a threshold to proceed",
+ "rule_test_fired": "Test notification sent successfully",
+ "no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
+ "button_testrule": "Test Notification",
+ "label_channel_select": "Notification Channels",
+ "placeholder_channel_select": "select one or more channels",
+ "channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
+ "preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
+ "preview_chart_threshold_label": "Threshold",
+ "placeholder_label_key_pair": "Click here to enter a label (key value pairs)",
+ "button_yes": "Yes",
+ "button_no": "No",
+ "remove_label_confirm": "This action will remove all the labels. Do you want to proceed?",
+ "remove_label_success": "Labels cleared",
+ "alert_form_step1": "Step 1 - Define the metric",
+ "alert_form_step2": "Step 2 - Define Alert Conditions",
+ "alert_form_step3": "Step 3 - Alert Configuration",
+ "metric_query_max_limit": "Can not create query. You can create maximum of 5 queries",
+ "confirm_save_title": "Save Changes",
+ "confirm_save_content_part1": "Your alert built with",
+ "confirm_save_content_part2": "query will be saved. Press OK to confirm.",
+ "unexpected_error": "Sorry, an unexpected error occurred. Please contact your admin",
+ "rule_created": "Rule created successfully",
+ "rule_edited": "Rule edited successfully",
+ "expression_missing": "expression is missing in {{where}}",
+ "metricname_missing": "metric name is missing in {{where}}",
+ "condition_required": "at least one metric condition is required",
+ "alertname_required": "alert name is required",
+ "promql_required": "promql expression is required when query format is set to PromQL",
+ "chquery_required": "query is required when query format is set to ClickHouse",
+ "button_savechanges": "Save Rule",
+ "button_createrule": "Create Rule",
+ "button_returntorules": "Return to rules",
+ "button_cancelchanges": "Cancel",
+ "button_discard": "Discard",
+ "text_condition1": "Send a notification when the metric is",
+ "text_condition2": "the threshold",
+ "text_condition3": "during the last",
+ "option_5min": "5 mins",
+ "option_10min": "10 mins",
+ "option_15min": "15 mins",
+ "option_60min": "60 mins",
+ "option_4hours": "4 hours",
+ "option_24hours": "24 hours",
+ "field_threshold": "Alert Threshold",
+ "option_allthetimes": "all the times",
+ "option_atleastonce": "at least once",
+ "option_onaverage": "on average",
+ "option_intotal": "in total",
+ "option_above": "above",
+ "option_below": "below",
+ "option_equal": "is equal to",
+ "option_notequal": "not equal to",
+ "button_query": "Query",
+ "button_formula": "Formula",
+ "tab_qb": "Query Builder",
+ "tab_promql": "PromQL",
+ "tab_chquery": "ClickHouse Query",
+ "title_confirm": "Confirm",
+ "button_ok": "Yes",
+ "button_cancel": "No",
+ "field_promql_expr": "PromQL Expression",
+ "field_alert_name": "Alert Name",
+ "field_alert_desc": "Alert Description",
+ "field_labels": "Labels",
+ "field_severity": "Severity",
+ "option_critical": "Critical",
+ "option_error": "Error",
+ "option_warning": "Warning",
+ "option_info": "Info",
+ "user_guide_headline": "Steps to create an Alert",
+ "user_guide_qb_step1": "Step 1 - Define the metric",
+ "user_guide_qb_step1a": "Choose a metric which you want to create an alert on",
+ "user_guide_qb_step1b": "Filter it based on WHERE field or GROUPBY if needed",
+ "user_guide_qb_step1c": "Apply an aggregatiion function like COUNT, SUM, etc. or choose NOOP to plot the raw metric",
+ "user_guide_qb_step1d": "Create a formula based on Queries if needed",
+ "user_guide_qb_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_qb_step2a": "Select the evaluation interval, threshold type and whether you want to alert above/below a value",
+ "user_guide_qb_step2b": "Enter the Alert threshold",
+ "user_guide_qb_step3": "Step 3 -Alert Configuration",
+ "user_guide_qb_step3a": "Set alert severity, name and descriptions",
+ "user_guide_qb_step3b": "Add tags to the alert in the Label field if needed",
+ "user_guide_pql_step1": "Step 1 - Define the metric",
+ "user_guide_pql_step1a": "Write a PromQL query for the metric",
+ "user_guide_pql_step1b": "Format the legends based on labels you want to highlight",
+ "user_guide_pql_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_pql_step2a": "Select the threshold type and whether you want to alert above/below a value",
+ "user_guide_pql_step2b": "Enter the Alert threshold",
+ "user_guide_pql_step3": "Step 3 -Alert Configuration",
+ "user_guide_pql_step3a": "Set alert severity, name and descriptions",
+ "user_guide_pql_step3b": "Add tags to the alert in the Label field if needed",
+ "user_guide_ch_step1": "Step 1 - Define the metric",
+ "user_guide_ch_step1a": "Write a Clickhouse query for alert evaluation. Follow <0>this tutorial</0> to learn about query format and supported vars.",
+ "user_guide_ch_step1b": "Format the legends based on labels you want to highlight in the preview chart",
+ "user_guide_ch_step2": "Step 2 - Define Alert Conditions",
+ "user_guide_ch_step2a": "Select the threshold type and whether you want to alert above/below a value",
+ "user_guide_ch_step2b": "Enter the Alert threshold",
+ "user_guide_ch_step3": "Step 3 -Alert Configuration",
+ "user_guide_ch_step3a": "Set alert severity, name and descriptions",
+ "user_guide_ch_step3b": "Add tags to the alert in the Label field if needed",
+ "user_tooltip_more_help": "More details on how to create alerts",
+ "choose_alert_type": "Choose a type for the alert:",
+ "metric_based_alert": "Metric based Alert",
+ "metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
+ "log_based_alert": "Log-based Alert",
+ "log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
+ "traces_based_alert": "Trace-based Alert",
+ "traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
+ "exceptions_based_alert": "Exceptions-based Alert",
+ "exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data.",
+ "field_unit": "Threshold unit"
+}
diff --git a/frontend/src/container/CreateAlertRule/defaults.ts b/frontend/src/container/CreateAlertRule/defaults.ts
index adc7c9154d..2ac2f3a7b8 100644
--- a/frontend/src/container/CreateAlertRule/defaults.ts
+++ b/frontend/src/container/CreateAlertRule/defaults.ts
@@ -40,6 +40,7 @@ export const alertDefaults: AlertDef = {
},
queryType: EQueryType.QUERY_BUILDER,
panelType: PANEL_TYPES.TIME_SERIES,
+ unit: undefined,
},
op: defaultCompareOp,
matchType: defaultMatchType,
@@ -69,6 +70,7 @@ export const logAlertDefaults: AlertDef = {
},
queryType: EQueryType.QUERY_BUILDER,
panelType: PANEL_TYPES.TIME_SERIES,
+ unit: undefined,
},
op: defaultCompareOp,
matchType: '4',
@@ -99,6 +101,7 @@ export const traceAlertDefaults: AlertDef = {
},
queryType: EQueryType.QUERY_BUILDER,
panelType: PANEL_TYPES.TIME_SERIES,
+ unit: undefined,
},
op: defaultCompareOp,
matchType: '4',
@@ -129,6 +132,7 @@ export const exceptionAlertDefaults: AlertDef = {
},
queryType: EQueryType.QUERY_BUILDER,
panelType: PANEL_TYPES.TIME_SERIES,
+ unit: undefined,
},
op: defaultCompareOp,
matchType: '4',
diff --git a/frontend/src/container/FormAlertRules/ChartPreview/config.ts b/frontend/src/container/FormAlertRules/ChartPreview/config.ts
new file mode 100644
index 0000000000..94001bbd8c
--- /dev/null
+++ b/frontend/src/container/FormAlertRules/ChartPreview/config.ts
@@ -0,0 +1,98 @@
+import {
+ DataFormats,
+ DataRateFormats,
+ MiscellaneousFormats,
+ ThroughputFormats,
+ TimeFormats,
+} from 'container/NewWidget/RightContainer/types';
+
+export const dataFormatConfig: Record<DataFormats, number> = {
+ [DataFormats.BytesIEC]: 1,
+ [DataFormats.BytesSI]: 1,
+ [DataFormats.BitsIEC]: 1 / 8,
+ [DataFormats.BitsSI]: 1 / 8,
+ [DataFormats.KibiBytes]: 1024,
+ [DataFormats.KiloBytes]: 1000,
+ [DataFormats.MebiBytes]: 1024 ** 2,
+ [DataFormats.MegaBytes]: 1000 ** 2,
+ [DataFormats.GibiBytes]: 1024 ** 3,
+ [DataFormats.GigaBytes]: 1000 ** 3,
+ [DataFormats.TebiBytes]: 1024 ** 4,
+ [DataFormats.TeraBytes]: 1000 ** 4,
+ [DataFormats.PebiBytes]: 1024 ** 5,
+ [DataFormats.PetaBytes]: 1000 ** 5,
+};
+
+export const throughputConfig: Record<ThroughputFormats, number> = {
+ [ThroughputFormats.CountsPerSec]: 1,
+ [ThroughputFormats.OpsPerSec]: 1,
+ [ThroughputFormats.RequestsPerSec]: 1,
+ [ThroughputFormats.ReadsPerSec]: 1,
+ [ThroughputFormats.WritesPerSec]: 1,
+ [ThroughputFormats.IOOpsPerSec]: 1,
+ [ThroughputFormats.CountsPerMin]: 1 / 60,
+ [ThroughputFormats.OpsPerMin]: 1 / 60,
+ [ThroughputFormats.ReadsPerMin]: 1 / 60,
+ [ThroughputFormats.WritesPerMin]: 1 / 60,
+};
+
+export const timeUnitsConfig: Record<TimeFormats, number> = {
+ [TimeFormats.Hertz]: 1,
+ [TimeFormats.Nanoseconds]: 1e-9,
+ [TimeFormats.Microseconds]: 1e-6,
+ [TimeFormats.Milliseconds]: 1e-3,
+ [TimeFormats.Seconds]: 1,
+ [TimeFormats.Minutes]: 60,
+ [TimeFormats.Hours]: 3600,
+ [TimeFormats.Days]: 86400,
+ [TimeFormats.DurationMs]: 1e-3,
+ [TimeFormats.DurationS]: 1,
+ [TimeFormats.DurationHms]: 3600,
+ [TimeFormats.DurationDhms]: 86400,
+ [TimeFormats.Timeticks]: 1e-3,
+ [TimeFormats.ClockMs]: 1e-3,
+ [TimeFormats.ClockS]: 1,
+};
+
+export const dataRateUnitsConfig: Record<DataRateFormats, number> = {
+ [DataRateFormats.PacketsPerSec]: 1,
+ [DataRateFormats.BytesPerSecIEC]: dataFormatConfig[DataFormats.BytesIEC],
+ [DataRateFormats.BytesPerSecSI]: dataFormatConfig[DataFormats.BytesSI],
+ [DataRateFormats.BitsPerSecIEC]: dataFormatConfig[DataFormats.BitsIEC],
+ [DataRateFormats.BitsPerSecSI]: dataFormatConfig[DataFormats.BitsSI],
+ [DataRateFormats.KibiBytesPerSec]: dataFormatConfig[DataFormats.KibiBytes],
+ [DataRateFormats.KibiBitsPerSec]: dataFormatConfig[DataFormats.KibiBytes] * 8,
+ [DataRateFormats.KiloBytesPerSec]: dataFormatConfig[DataFormats.KiloBytes],
+ [DataRateFormats.KiloBitsPerSec]: dataFormatConfig[DataFormats.KiloBytes] * 8,
+ [DataRateFormats.MebiBytesPerSec]: dataFormatConfig[DataFormats.MebiBytes],
+ [DataRateFormats.MebiBitsPerSec]: dataFormatConfig[DataFormats.MebiBytes] * 8,
+ [DataRateFormats.MegaBytesPerSec]: dataFormatConfig[DataFormats.MegaBytes],
+ [DataRateFormats.MegaBitsPerSec]: dataFormatConfig[DataFormats.MegaBytes] * 8,
+ [DataRateFormats.GibiBytesPerSec]: dataFormatConfig[DataFormats.GibiBytes],
+ [DataRateFormats.GibiBitsPerSec]: dataFormatConfig[DataFormats.GibiBytes] * 8,
+ [DataRateFormats.GigaBytesPerSec]: dataFormatConfig[DataFormats.GigaBytes],
+ [DataRateFormats.GigaBitsPerSec]: dataFormatConfig[DataFormats.GigaBytes] * 8,
+ [DataRateFormats.TebiBytesPerSec]: dataFormatConfig[DataFormats.TebiBytes],
+ [DataRateFormats.TebiBitsPerSec]: dataFormatConfig[DataFormats.TebiBytes] * 8,
+ [DataRateFormats.TeraBytesPerSec]: dataFormatConfig[DataFormats.TeraBytes],
+ [DataRateFormats.TeraBitsPerSec]: dataFormatConfig[DataFormats.TeraBytes] * 8,
+ [DataRateFormats.PebiBytesPerSec]: dataFormatConfig[DataFormats.PebiBytes],
+ [DataRateFormats.PebiBitsPerSec]: dataFormatConfig[DataFormats.PebiBytes] * 8,
+ [DataRateFormats.PetaBytesPerSec]: dataFormatConfig[DataFormats.PetaBytes],
+ [DataRateFormats.PetaBitsPerSec]: dataFormatConfig[DataFormats.PetaBytes] * 8,
+};
+
+export const miscUnitsConfig: Record<MiscellaneousFormats, number> = {
+ [MiscellaneousFormats.None]: 1,
+ [MiscellaneousFormats.String]: 1,
+ [MiscellaneousFormats.Short]: 1,
+ [MiscellaneousFormats.Percent]: 0.01,
+ [MiscellaneousFormats.PercentUnit]: 1,
+ [MiscellaneousFormats.Humidity]: 1,
+ [MiscellaneousFormats.Decibel]: 1,
+ [MiscellaneousFormats.Hexadecimal0x]: 1,
+ [MiscellaneousFormats.Hexadecimal]: 1,
+ [MiscellaneousFormats.ScientificNotation]: 1,
+ [MiscellaneousFormats.LocaleFormat]: 1,
+ [MiscellaneousFormats.Pixels]: 1,
+};
diff --git a/frontend/src/container/FormAlertRules/ChartPreview/index.tsx b/frontend/src/container/FormAlertRules/ChartPreview/index.tsx
index 33bcfa3c37..f6bf35cbd7 100644
--- a/frontend/src/container/FormAlertRules/ChartPreview/index.tsx
+++ b/frontend/src/container/FormAlertRules/ChartPreview/index.tsx
@@ -9,10 +9,12 @@ import { useGetQueryRange } from 'hooks/queryBuilder/useGetQueryRange';
import getChartData from 'lib/getChartData';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { AlertDef } from 'types/api/alerts/def';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
import { ChartContainer, FailedMessageContainer } from './styles';
+import { covertIntoDataFormats } from './utils';
export interface ChartPreviewProps {
name: string;
@@ -21,7 +23,7 @@ export interface ChartPreviewProps {
selectedTime?: timePreferenceType;
selectedInterval?: Time;
headline?: JSX.Element;
- threshold?: number | undefined;
+ alertDef?: AlertDef;
userQueryKey?: string;
}
@@ -32,18 +34,28 @@ function ChartPreview({
selectedTime = 'GLOBAL_TIME',
selectedInterval = '5min',
headline,
- threshold,
userQueryKey,
+ alertDef,
}: ChartPreviewProps): JSX.Element | null {
const { t } = useTranslation('alerts');
+ const threshold = alertDef?.condition.target || 0;
+
+ const thresholdValue = covertIntoDataFormats({
+ value: threshold,
+ sourceUnit: alertDef?.condition.targetUnit,
+ targetUnit: query?.unit,
+ });
+
const staticLine: StaticLineProps | undefined =
threshold !== undefined
? {
- yMin: threshold,
- yMax: threshold,
+ yMin: thresholdValue,
+ yMax: thresholdValue,
borderColor: '#f14',
borderWidth: 1,
- lineText: `${t('preview_chart_threshold_label')} (y=${threshold})`,
+ lineText: `${t('preview_chart_threshold_label')} (y=${thresholdValue} ${
+ query?.unit || ''
+ })`,
textColor: '#f14',
}
: undefined;
@@ -121,6 +133,7 @@ function ChartPreview({
staticLine={staticLine}
panelData={queryResponse.data?.payload.data.newResult.data.result || []}
query={query || initialQueriesMap.metrics}
+ yAxisUnit={query?.unit}
/>
)}
</ChartContainer>
@@ -132,8 +145,8 @@ ChartPreview.defaultProps = {
selectedTime: 'GLOBAL_TIME',
selectedInterval: '5min',
headline: undefined,
- threshold: undefined,
userQueryKey: '',
+ alertDef: undefined,
};
export default ChartPreview;
diff --git a/frontend/src/container/FormAlertRules/ChartPreview/utils.test.ts b/frontend/src/container/FormAlertRules/ChartPreview/utils.test.ts
new file mode 100644
index 0000000000..e81b57b933
--- /dev/null
+++ b/frontend/src/container/FormAlertRules/ChartPreview/utils.test.ts
@@ -0,0 +1,105 @@
+import { DataFormats } from 'container/NewWidget/RightContainer/types';
+
+import { covertIntoDataFormats } from './utils';
+
+describe('Convert One Unit to another unit', () => {
+ it('should convert from BitsIEC to BytesIEC', () => {
+ const result = covertIntoDataFormats({
+ value: 8,
+ sourceUnit: DataFormats.BitsIEC,
+ targetUnit: DataFormats.BytesIEC,
+ });
+ expect(result).toBe(1);
+ });
+
+ // for KibiBytes to MebiBytes conversion
+ it('should convert from KibiBytes to MebiBytes', () => {
+ const result = covertIntoDataFormats({
+ value: 1024,
+ sourceUnit: DataFormats.KibiBytes,
+ targetUnit: DataFormats.MebiBytes,
+ });
+ expect(result).toBe(1);
+ });
+
+ // for MegaBytes to GigaBytes conversion (SI units)
+ it('should convert from MegaBytes to GigaBytes (SI)', () => {
+ const result = covertIntoDataFormats({
+ value: 1000,
+ sourceUnit: DataFormats.MegaBytes,
+ targetUnit: DataFormats.GigaBytes,
+ });
+ expect(result).toBe(1);
+ });
+
+ // for identity conversion
+ it('should handle identity conversion', () => {
+ const result = covertIntoDataFormats({
+ value: 100,
+ sourceUnit: DataFormats.KibiBytes,
+ targetUnit: DataFormats.KibiBytes,
+ });
+ expect(result).toBe(100);
+ });
+
+ // BytesIEC to BitsIEC conversion
+ it('should convert from BytesIEC to BitsIEC', () => {
+ const result = covertIntoDataFormats({
+ value: 1,
+ sourceUnit: DataFormats.BytesIEC,
+ targetUnit: DataFormats.BitsIEC,
+ });
+ expect(result).toBe(8);
+ });
+
+ // for GibiBytes to TebiBytes conversion
+ it('should convert from GibiBytes to TebiBytes', () => {
+ const result = covertIntoDataFormats({
+ value: 1024,
+ sourceUnit: DataFormats.GibiBytes,
+ targetUnit: DataFormats.TebiBytes,
+ });
+ expect(result).toBe(1);
+ });
+
+ // for GigaBytes to TeraBytes conversion (SI units)
+ it('should convert from GigaBytes to TeraBytes (SI)', () => {
+ const result = covertIntoDataFormats({
+ value: 1000,
+ sourceUnit: DataFormats.GigaBytes,
+ targetUnit: DataFormats.TeraBytes,
+ });
+ expect(result).toBe(1);
+ });
+
+ // for GigaBytes to GibiBytes conversion (cross conversion)
+ it('should convert from GigaBytes to GibiBytes', () => {
+ const result = covertIntoDataFormats({
+ value: 1,
+ sourceUnit: DataFormats.GigaBytes,
+ targetUnit: DataFormats.GibiBytes,
+ });
+ // 1 GB = 0.93132257461548 GiB approximately
+ expect(result).toBeCloseTo(0.93132257461548);
+ });
+
+ // for a large number conversion
+ it('should handle large number conversion from PebiBytes to BitsIEC', () => {
+ const result = covertIntoDataFormats({
+ value: 1,
+ sourceUnit: DataFormats.PebiBytes,
+ targetUnit: DataFormats.BitsIEC,
+ });
+ expect(result).toBe(1 * 1024 ** 5 * 8); // 1 PebiByte = 2^50 Bytes = 2^53 Bits
+ });
+
+ // Negative value conversion
+ it('should handle negative values', () => {
+ const result = covertIntoDataFormats({
+ value: -1,
+ sourceUnit: DataFormats.KibiBytes,
+ targetUnit: DataFormats.BytesIEC,
+ });
+ expect(result).toBe(-1024);
+ });
+});
diff --git a/frontend/src/container/FormAlertRules/ChartPreview/utils.ts b/frontend/src/container/FormAlertRules/ChartPreview/utils.ts
new file mode 100644
index 0000000000..0dbcc21603
--- /dev/null
+++ b/frontend/src/container/FormAlertRules/ChartPreview/utils.ts
@@ -0,0 +1,54 @@
+import {
+ BooleanFormats,
+ DataFormats,
+ DataRateFormats,
+ MiscellaneousFormats,
+ ThroughputFormats,
+ TimeFormats,
+} from 'container/NewWidget/RightContainer/types';
+
+import {
+ dataFormatConfig,
+ dataRateUnitsConfig,
+ miscUnitsConfig,
+ throughputConfig,
+ timeUnitsConfig,
+} from './config';
+
+export function covertIntoDataFormats({
+ value,
+ sourceUnit,
+ targetUnit,
+}: IUnit): number {
+ if (Object.values(BooleanFormats).includes(sourceUnit as BooleanFormats)) {
+ return 1;
+ }
+
+ const sourceMultiplier =
+ dataFormatConfig[sourceUnit as DataFormats] ||
+ timeUnitsConfig[sourceUnit as TimeFormats] ||
+ dataRateUnitsConfig[sourceUnit as DataRateFormats] ||
+ miscUnitsConfig[sourceUnit as MiscellaneousFormats] ||
+ throughputConfig[sourceUnit as ThroughputFormats];
+
+ const targetDivider =
+ dataFormatConfig[targetUnit as DataFormats] ||
+ timeUnitsConfig[targetUnit as TimeFormats] ||
+ dataRateUnitsConfig[targetUnit as DataRateFormats] ||
+ miscUnitsConfig[targetUnit as MiscellaneousFormats] ||
+ throughputConfig[sourceUnit as ThroughputFormats];
+
+ const intermediateValue = value * sourceMultiplier;
+
+ const roundedValue = Math.round(intermediateValue * 1000000) / 1000000;
+
+ const result = roundedValue / targetDivider;
+
+ return Number.isNaN(result) ? 0 : result;
+}
+
+interface IUnit {
+ value: number;
+ sourceUnit?: string;
+ targetUnit?: string;
+}
diff --git a/frontend/src/container/FormAlertRules/RuleOptions.tsx b/frontend/src/container/FormAlertRules/RuleOptions.tsx
index 22238a941b..8ece1562fe 100644
--- a/frontend/src/container/FormAlertRules/RuleOptions.tsx
+++ b/frontend/src/container/FormAlertRules/RuleOptions.tsx
@@ -1,4 +1,17 @@
-import { Form, InputNumber, InputNumberProps, Select, Typography } from 'antd';
+import {
+ Form,
+ InputNumber,
+ InputNumberProps,
+ Select,
+ SelectProps,
+ Space,
+ Typography,
+} from 'antd';
+import {
+ getCategoryByOptionId,
+ getCategorySelectOptionByName,
+} from 'container/NewWidget/RightContainer/alertFomatCategories';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useTranslation } from 'react-i18next';
import {
AlertDef,
@@ -10,9 +23,6 @@ import { EQueryType } from 'types/common/dashboard';
import { FormContainer, InlineSelect, StepHeading } from './styles';
-const { Option } = Select;
-const FormItem = Form.Item;
-
function RuleOptions({
alertDef,
setAlertDef,
@@ -20,6 +30,7 @@ function RuleOptions({
}: RuleOptionsProps): JSX.Element {
// init namespace for translations
const { t } = useTranslation('alerts');
+ const { currentQuery } = useQueryBuilder();
const handleMatchOptChange = (value: string | unknown): void => {
const m = (value as string) || alertDef.condition?.matchType;
@@ -49,10 +60,10 @@ function RuleOptions({
});
}}
>
- <Option value="1">{t('option_above')}</Option>
- <Option value="2">{t('option_below')}</Option>
- <Option value="3">{t('option_equal')}</Option>
- <Option value="4">{t('option_notequal')}</Option>
+ <Select.Option value="1">{t('option_above')}</Select.Option>
+ <Select.Option value="2">{t('option_below')}</Select.Option>
+ <Select.Option value="3">{t('option_equal')}</Select.Option>
+ <Select.Option value="4">{t('option_notequal')}</Select.Option>
</InlineSelect>
);
@@ -63,10 +74,10 @@ function RuleOptions({
value={alertDef.condition?.matchType}
onChange={(value: string | unknown): void => handleMatchOptChange(value)}
>
- <Option value="1">{t('option_atleastonce')}</Option>
- <Option value="2">{t('option_allthetimes')}</Option>
- <Option value="3">{t('option_onaverage')}</Option>
- <Option value="4">{t('option_intotal')}</Option>
+ <Select.Option value="1">{t('option_atleastonce')}</Select.Option>
+ <Select.Option value="2">{t('option_allthetimes')}</Select.Option>
+ <Select.Option value="3">{t('option_onaverage')}</Select.Option>
+ <Select.Option value="4">{t('option_intotal')}</Select.Option>
</InlineSelect>
);
@@ -77,7 +88,7 @@ function RuleOptions({
value={alertDef.condition?.matchType}
onChange={(value: string | unknown): void => handleMatchOptChange(value)}
>
- <Option value="1">{t('option_atleastonce')}</Option>
+ <Select.Option value="1">{t('option_atleastonce')}</Select.Option>
</InlineSelect>
);
@@ -94,31 +105,30 @@ function RuleOptions({
});
}}
>
- {' '}
- <Option value="5m0s">{t('option_5min')}</Option>
- <Option value="10m0s">{t('option_10min')}</Option>
- <Option value="15m0s">{t('option_15min')}</Option>
- <Option value="1h0m0s">{t('option_60min')}</Option>
- <Option value="4h0m0s">{t('option_4hours')}</Option>
- <Option value="24h0m0s">{t('option_24hours')}</Option>
+ <Select.Option value="5m0s">{t('option_5min')}</Select.Option>
+ <Select.Option value="10m0s">{t('option_10min')}</Select.Option>
+ <Select.Option value="15m0s">{t('option_15min')}</Select.Option>
+ <Select.Option value="1h0m0s">{t('option_60min')}</Select.Option>
+ <Select.Option value="4h0m0s">{t('option_4hours')}</Select.Option>
+ <Select.Option value="24h0m0s">{t('option_24hours')}</Select.Option>
</InlineSelect>
);
const renderThresholdRuleOpts = (): JSX.Element => (
- <FormItem>
+ <Form.Item>
<Typography.Text>
{t('text_condition1')} {renderCompareOps()} {t('text_condition2')}{' '}
{renderThresholdMatchOpts()} {t('text_condition3')} {renderEvalWindows()}
</Typography.Text>
- </FormItem>
+ </Form.Item>
);
const renderPromRuleOptions = (): JSX.Element => (
- <FormItem>
+ <Form.Item>
<Typography.Text>
{t('text_condition1')} {renderCompareOps()} {t('text_condition2')}{' '}
{renderPromMatchOpts()}
</Typography.Text>
- </FormItem>
+ </Form.Item>
);
const onChange: InputNumberProps['onChange'] = (value): void => {
@@ -133,6 +143,22 @@ function RuleOptions({
});
};
+ const onChangeAlertUnit: SelectProps['onChange'] = (value) => {
+ setAlertDef({
+ ...alertDef,
+ condition: {
+ ...alertDef.condition,
+ targetUnit: value as string,
+ },
+ });
+ };
+
+ const selectedCategory = getCategoryByOptionId(currentQuery?.unit || '');
+
+ const categorySelectOptions = getCategorySelectOptionByName(
+ selectedCategory?.name,
+ );
+
return (
<>
<StepHeading>{t('alert_form_step2')}</StepHeading>
@@ -140,14 +166,29 @@ function RuleOptions({
{queryCategory === EQueryType.PROM
? renderPromRuleOptions()
: renderThresholdRuleOpts()}
- <Form.Item name={['condition', 'target']}>
- <InputNumber
- addonBefore={t('field_threshold')}
- value={alertDef?.condition?.target}
- onChange={onChange}
- type="number"
- />
- </Form.Item>
+
+ <Space align="start">
+ <Form.Item noStyle name={['condition', 'target']}>
+ <InputNumber
+ addonBefore={t('field_threshold')}
+ value={alertDef?.condition?.target}
+ onChange={onChange}
+ type="number"
+ onWheel={(e): void => e.currentTarget.blur()}
+ />
+ </Form.Item>
+
+ <Form.Item>
+ <Select
+ allowClear
+ showSearch
+ options={categorySelectOptions}
+ placeholder={t('field_unit')}
+ value={alertDef.condition.targetUnit}
+ onChange={onChangeAlertUnit}
+ />
+ </Form.Item>
+ </Space>
</FormContainer>
</>
);
diff --git a/frontend/src/container/FormAlertRules/index.tsx b/frontend/src/container/FormAlertRules/index.tsx
index 109e3ea9d5..f018df5641 100644
--- a/frontend/src/container/FormAlertRules/index.tsx
+++ b/frontend/src/container/FormAlertRules/index.tsx
@@ -7,6 +7,7 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import QueryTypeTag from 'container/NewWidget/LeftContainer/QueryTypeTag';
import PlotTag from 'container/NewWidget/LeftContainer/WidgetGraph/PlotTag';
+import { BuilderUnitsFilter } from 'container/QueryBuilder/filters';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
import { updateStepInterval } from 'hooks/queryBuilder/useStepInterval';
@@ -39,6 +40,7 @@ import {
ButtonContainer,
MainFormContainer,
PanelContainer,
+ StepContainer,
StyledLeftContainer,
} from './styles';
import UserGuide from './UserGuide';
@@ -224,6 +226,7 @@ function FormAlertRules({
chQueries: mapQueryDataToApi(currentQuery.clickhouse_sql, 'name').data,
queryType: currentQuery.queryType,
panelType: initQuery.panelType,
+ unit: currentQuery.unit,
},
},
};
@@ -360,9 +363,9 @@ function FormAlertRules({
/>
}
name=""
- threshold={alertDef.condition?.target}
query={stagedQuery}
selectedInterval={toChartInterval(alertDef.evalWindow)}
+ alertDef={alertDef}
/>
);
@@ -375,8 +378,8 @@ function FormAlertRules({
/>
}
name="Chart Preview"
- threshold={alertDef.condition?.target}
query={stagedQuery}
+ alertDef={alertDef}
/>
);
@@ -389,8 +392,8 @@ function FormAlertRules({
/>
}
name="Chart Preview"
- threshold={alertDef.condition?.target}
query={stagedQuery}
+ alertDef={alertDef}
selectedInterval={toChartInterval(alertDef.evalWindow)}
/>
);
@@ -404,9 +407,21 @@ function FormAlertRules({
currentQuery.queryType === EQueryType.QUERY_BUILDER &&
alertType !== AlertTypes.METRICS_BASED_ALERT;
+ const onUnitChangeHandler = (): void => {
+ // reset target unit
+ setAlertDef((def) => ({
+ ...def,
+ condition: {
+ ...def.condition,
+ targetUnit: undefined,
+ },
+ }));
+ };
+
return (
<>
{Element}
+
<PanelContainer>
<StyledLeftContainer flex="5 1 600px" md={18}>
<MainFormContainer
@@ -419,6 +434,11 @@ function FormAlertRules({
{currentQuery.queryType === EQueryType.PROM && renderPromChartPreview()}
{currentQuery.queryType === EQueryType.CLICKHOUSE &&
renderChQueryChartPreview()}
+
+ <StepContainer>
+ <BuilderUnitsFilter onChange={onUnitChangeHandler} />
+ </StepContainer>
+
<QuerySection
queryCategory={currentQuery.queryType}
setQueryCategory={onQueryCategoryChange}
diff --git a/frontend/src/container/FormAlertRules/styles.ts b/frontend/src/container/FormAlertRules/styles.ts
index 60e733527a..f0b9dff66e 100644
--- a/frontend/src/container/FormAlertRules/styles.ts
+++ b/frontend/src/container/FormAlertRules/styles.ts
@@ -89,3 +89,7 @@ export const FormItemMedium = styled(Item)`
export const ChannelSelectTip = styled(Typography.Text)`
color: hsla(0, 0%, 100%, 0.3);
`;
+
+export const StepContainer = styled.div`
+ margin-top: 2rem;
+`;
diff --git a/frontend/src/container/NewWidget/RightContainer/alertFomatCategories.ts b/frontend/src/container/NewWidget/RightContainer/alertFomatCategories.ts
new file mode 100644
index 0000000000..b9ad3feb18
--- /dev/null
+++ b/frontend/src/container/NewWidget/RightContainer/alertFomatCategories.ts
@@ -0,0 +1,121 @@
+import { DefaultOptionType } from 'antd/es/select';
+
+import {
+ BooleanFormats,
+ Category,
+ CategoryNames,
+ DataFormats,
+ DataRateFormats,
+ MiscellaneousFormats,
+ ThroughputFormats,
+ TimeFormats,
+} from './types';
+
+export const alertsCategory = [
+ {
+ name: CategoryNames.Time,
+ formats: [
+ { name: 'nanoseconds (ns)', id: TimeFormats.Nanoseconds },
+ { name: 'microseconds (µs)', id: TimeFormats.Microseconds },
+ { name: 'milliseconds (ms)', id: TimeFormats.Milliseconds },
+ { name: 'seconds (s)', id: TimeFormats.Seconds },
+ { name: 'minutes (m)', id: TimeFormats.Minutes },
+ { name: 'hours (h)', id: TimeFormats.Hours },
+ { name: 'days (d)', id: TimeFormats.Days },
+ ],
+ },
+ {
+ name: CategoryNames.Data,
+ formats: [
+ { name: 'bytes(IEC)', id: DataFormats.BytesIEC },
+ { name: 'bytes(SI)', id: DataFormats.BytesSI },
+ { name: 'bits(IEC)', id: DataFormats.BitsIEC },
+ { name: 'bits(SI)', id: DataFormats.BitsSI },
+ { name: 'kibibytes', id: DataFormats.KibiBytes },
+ { name: 'kilobytes', id: DataFormats.KiloBytes },
+ { name: 'mebibytes', id: DataFormats.MebiBytes },
+ { name: 'megabytes', id: DataFormats.MegaBytes },
+ { name: 'gibibytes', id: DataFormats.GibiBytes },
+ { name: 'gigabytes', id: DataFormats.GigaBytes },
+ { name: 'tebibytes', id: DataFormats.TebiBytes },
+ { name: 'terabytes', id: DataFormats.TeraBytes },
+ { name: 'pebibytes', id: DataFormats.PebiBytes },
+ { name: 'petabytes', id: DataFormats.PetaBytes },
+ ],
+ },
+ {
+ name: CategoryNames.DataRate,
+ formats: [
+ { name: 'bytes/sec(IEC)', id: DataRateFormats.BytesPerSecIEC },
+ { name: 'bytes/sec(SI)', id: DataRateFormats.BytesPerSecSI },
+ { name: 'bits/sec(IEC)', id: DataRateFormats.BitsPerSecIEC },
+ { name: 'bits/sec(SI)', id: DataRateFormats.BitsPerSecSI },
+ { name: 'kibibytes/sec', id: DataRateFormats.KibiBytesPerSec },
+ { name: 'kibibits/sec', id: DataRateFormats.KibiBitsPerSec },
+ { name: 'kilobytes/sec', id: DataRateFormats.KiloBytesPerSec },
+ { name: 'kilobits/sec', id: DataRateFormats.KiloBitsPerSec },
+ { name: 'mebibytes/sec', id: DataRateFormats.MebiBytesPerSec },
+ { name: 'mebibits/sec', id: DataRateFormats.MebiBitsPerSec },
+ { name: 'megabytes/sec', id: DataRateFormats.MegaBytesPerSec },
+ { name: 'megabits/sec', id: DataRateFormats.MegaBitsPerSec },
+ { name: 'gibibytes/sec', id: DataRateFormats.GibiBytesPerSec },
+ { name: 'gibibits/sec', id: DataRateFormats.GibiBitsPerSec },
+ { name: 'gigabytes/sec', id: DataRateFormats.GigaBytesPerSec },
+ { name: 'gigabits/sec', id: DataRateFormats.GigaBitsPerSec },
+ { name: 'tebibytes/sec', id: DataRateFormats.TebiBytesPerSec },
+ { name: 'tebibits/sec', id: DataRateFormats.TebiBitsPerSec },
+ { name: 'terabytes/sec', id: DataRateFormats.TeraBytesPerSec },
+ { name: 'terabits/sec', id: DataRateFormats.TeraBitsPerSec },
+ { name: 'pebibytes/sec', id: DataRateFormats.PebiBytesPerSec },
+ { name: 'pebibits/sec', id: DataRateFormats.PebiBitsPerSec },
+ { name: 'petabytes/sec', id: DataRateFormats.PetaBytesPerSec },
+ { name: 'petabits/sec', id: DataRateFormats.PetaBitsPerSec },
+ ],
+ },
+ {
+ name: CategoryNames.Miscellaneous,
+ formats: [
+ { name: 'Percent (0.0-1.0)', id: MiscellaneousFormats.PercentUnit },
+ ],
+ },
+ {
+ name: CategoryNames.Boolean,
+ formats: [
+ { name: 'True / False', id: BooleanFormats.TRUE_FALSE },
+ { name: 'Yes / No', id: BooleanFormats.YES_NO },
+ ],
+ },
+ {
+ name: CategoryNames.Throughput,
+ formats: [
+ { name: 'counts/sec (cps)', id: ThroughputFormats.CountsPerSec },
+ { name: 'ops/sec (ops)', id: ThroughputFormats.OpsPerSec },
+ { name: 'requests/sec (reqps)', id: ThroughputFormats.RequestsPerSec },
+ { name: 'reads/sec (rps)', id: ThroughputFormats.ReadsPerSec },
+ { name: 'writes/sec (wps)', id: ThroughputFormats.WritesPerSec },
+ { name: 'I/O operations/sec (iops)', id: ThroughputFormats.IOOpsPerSec },
+ { name: 'counts/min (cpm)', id: ThroughputFormats.CountsPerMin },
+ { name: 'ops/min (opm)', id: ThroughputFormats.OpsPerMin },
+ { name: 'reads/min (rpm)', id: ThroughputFormats.ReadsPerMin },
+ { name: 'writes/min (wpm)', id: ThroughputFormats.WritesPerMin },
+ ],
+ },
+];
+
+export const getCategorySelectOptionByName = (
+ name?: CategoryNames | string,
+): DefaultOptionType[] =>
+ alertsCategory
+ .find((category) => category.name === name)
+ ?.formats.map((format) => ({
+ label: format.name,
+ value: format.id,
+ })) || [];
+
+export const getCategoryByOptionId = (id: string): Category | undefined =>
+ alertsCategory.find((category) =>
+ category.formats.some((format) => format.id === id),
+ );
+
+export const isCategoryName = (name: string): name is CategoryNames =>
+ alertsCategory.some((category) => category.name === name);
diff --git a/frontend/src/container/NewWidget/RightContainer/dataFormatCategories.ts b/frontend/src/container/NewWidget/RightContainer/dataFormatCategories.ts
index fcf5aea58a..c1b4944d53 100644
--- a/frontend/src/container/NewWidget/RightContainer/dataFormatCategories.ts
+++ b/frontend/src/container/NewWidget/RightContainer/dataFormatCategories.ts
@@ -1,383 +1,436 @@
import { flattenDeep } from 'lodash-es';
-export const dataTypeCategories = [
+import {
+ AccelerationFormats,
+ AngularFormats,
+ AreaFormats,
+ BooleanFormats,
+ CategoryNames,
+ ConcentrationFormats,
+ CurrencyFormats,
+ DataFormats,
+ DataRateFormats,
+ DataTypeCategories,
+ DatetimeFormats,
+ FlopsFormats,
+ FlowFormats,
+ ForceFormats,
+ HashRateFormats,
+ LengthFormats,
+ MassFormats,
+ MiscellaneousFormats,
+ PowerElectricalFormats,
+ PressureFormats,
+ RadiationFormats,
+ RotationSpeedFormats,
+ TemperatureFormats,
+ ThroughputFormats,
+ TimeFormats,
+ VelocityFormats,
+ VolumeFormats,
+} from './types';
+
+export const dataTypeCategories: DataTypeCategories = [
{
- name: 'Time',
+ name: CategoryNames.Time,
formats: [
- { name: 'Hertz (1/s)', id: 'hertz' },
- { name: 'nanoseconds (ns)', id: 'ns' },
- { name: 'microseconds (µs)', id: 'µs' },
- { name: 'milliseconds (ms)', id: 'ms' },
- { name: 'seconds (s)', id: 's' },
- { name: 'minutes (m)', id: 'm' },
- { name: 'hours (h)', id: 'h' },
- { name: 'days (d)', id: 'd' },
- { name: 'duration (ms)', id: 'dtdurationms' },
- { name: 'duration (s)', id: 'dtdurations' },
- { name: 'duration (hh:mm:ss)', id: 'dthms' },
- { name: 'duration (d hh:mm:ss)', id: 'dtdhms' },
- { name: 'Timeticks (s/100)', id: 'timeticks' },
- { name: 'clock (ms)', id: 'clockms' },
- { name: 'clock (s)', id: 'clocks' },
+ { name: 'Hertz (1/s)', id: TimeFormats.Hertz },
+ { name: 'nanoseconds (ns)', id: TimeFormats.Nanoseconds },
+ { name: 'microseconds (µs)', id: TimeFormats.Microseconds },
+ { name: 'milliseconds (ms)', id: TimeFormats.Milliseconds },
+ { name: 'seconds (s)', id: TimeFormats.Seconds },
+ { name: 'minutes (m)', id: TimeFormats.Minutes },
+ { name: 'hours (h)', id: TimeFormats.Hours },
+ { name: 'days (d)', id: TimeFormats.Days },
+ { name: 'duration in ms (dtdurationms)', id: TimeFormats.DurationMs },
+ { name: 'duration in s (dtdurations)', id: TimeFormats.DurationS },
+ { name: 'duration in h:m:s (dthms)', id: TimeFormats.DurationHms },
+ { name: 'duration in d:h:m:s (dtdhms)', id: TimeFormats.DurationDhms },
+ { name: 'timeticks (timeticks)', id: TimeFormats.Timeticks },
+ { name: 'clock in ms (clockms)', id: TimeFormats.ClockMs },
+ { name: 'clock in s (clocks)', id: TimeFormats.ClockS },
],
},
{
- name: 'Throughput',
+ name: CategoryNames.Throughput,
formats: [
- { name: 'counts/sec (cps)', id: 'cps' },
- { name: 'ops/sec (ops)', id: 'ops' },
- { name: 'requests/sec (rps)', id: 'reqps' },
- { name: 'reads/sec (rps)', id: 'rps' },
- { name: 'writes/sec (wps)', id: 'wps' },
- { name: 'I/O ops/sec (iops)', id: 'iops' },
- { name: 'counts/min (cpm)', id: 'cpm' },
- { name: 'ops/min (opm)', id: 'opm' },
- { name: 'reads/min (rpm)', id: 'rpm' },
- { name: 'writes/min (wpm)', id: 'wpm' },
+ { name: 'counts/sec (cps)', id: ThroughputFormats.CountsPerSec },
+ { name: 'ops/sec (ops)', id: ThroughputFormats.OpsPerSec },
+ { name: 'requests/sec (reqps)', id: ThroughputFormats.RequestsPerSec },
+ { name: 'reads/sec (rps)', id: ThroughputFormats.ReadsPerSec },
+ { name: 'writes/sec (wps)', id: ThroughputFormats.WritesPerSec },
+ { name: 'I/O operations/sec (iops)', id: ThroughputFormats.IOOpsPerSec },
+ { name: 'counts/min (cpm)', id: ThroughputFormats.CountsPerMin },
+ { name: 'ops/min (opm)', id: ThroughputFormats.OpsPerMin },
+ { name: 'reads/min (rpm)', id: ThroughputFormats.ReadsPerMin },
+ { name: 'writes/min (wpm)', id: ThroughputFormats.WritesPerMin },
],
},
{
- name: 'Data',
+ name: CategoryNames.Data,
formats: [
- { name: 'bytes(IEC)', id: 'bytes' },
- { name: 'bytes(SI)', id: 'decbytes' },
- { name: 'bits(IEC)', id: 'bits' },
- { name: 'bits(SI)', id: 'decbits' },
- { name: 'kibibytes', id: 'kbytes' },
- { name: 'kilobytes', id: 'deckbytes' },
- { name: 'mebibytes', id: 'mbytes' },
- { name: 'megabytes', id: 'decmbytes' },
- { name: 'gibibytes', id: 'gbytes' },
- { name: 'gigabytes', id: 'decgbytes' },
- { name: 'tebibytes', id: 'tbytes' },
- { name: 'terabytes', id: 'dectbytes' },
- { name: 'pebibytes', id: 'pbytes' },
- { name: 'petabytes', id: 'decpbytes' },
+ { name: 'bytes(IEC)', id: DataFormats.BytesIEC },
+ { name: 'bytes(SI)', id: DataFormats.BytesSI },
+ { name: 'bits(IEC)', id: DataFormats.BitsIEC },
+ { name: 'bits(SI)', id: DataFormats.BitsSI },
+ { name: 'kibibytes', id: DataFormats.KibiBytes },
+ { name: 'kilobytes', id: DataFormats.KiloBytes },
+ { name: 'mebibytes', id: DataFormats.MebiBytes },
+ { name: 'megabytes', id: DataFormats.MegaBytes },
+ { name: 'gibibytes', id: DataFormats.GibiBytes },
+ { name: 'gigabytes', id: DataFormats.GigaBytes },
+ { name: 'tebibytes', id: DataFormats.TebiBytes },
+ { name: 'terabytes', id: DataFormats.TeraBytes },
+ { name: 'pebibytes', id: DataFormats.PebiBytes },
+ { name: 'petabytes', id: DataFormats.PetaBytes },
],
},
{
- name: 'Data rate',
+ name: CategoryNames.DataRate,
formats: [
- { name: 'packets/sec', id: 'pps' },
- { name: 'bytes/sec(IEC)', id: 'binBps' },
- { name: 'bytes/sec(SI)', id: 'Bps' },
- { name: 'bits/sec(IEC)', id: 'binbps' },
- { name: 'bits/sec(SI)', id: 'bps' },
- { name: 'kibibytes/sec', id: 'KiBs' },
- { name: 'kibibits/sec', id: 'Kibits' },
- { name: 'kilobytes/sec', id: 'KBs' },
- { name: 'kilobits/sec', id: 'Kbits' },
- { name: 'mebibytes/sec', id: 'MiBs' },
- { name: 'mebibits/sec', id: 'Mibits' },
- { name: 'megabytes/sec', id: 'MBs' },
- { name: 'megabits/sec', id: 'Mbits' },
- { name: 'gibibytes/sec', id: 'GiBs' },
- { name: 'gibibits/sec', id: 'Gibits' },
- { name: 'gigabytes/sec', id: 'GBs' },
- { name: 'gigabits/sec', id: 'Gbits' },
- { name: 'tebibytes/sec', id: 'TiBs' },
- { name: 'tebibits/sec', id: 'Tibits' },
- { name: 'terabytes/sec', id: 'TBs' },
- { name: 'terabits/sec', id: 'Tbits' },
- { name: 'pebibytes/sec', id: 'PiBs' },
- { name: 'pebibits/sec', id: 'Pibits' },
- { name: 'petabytes/sec', id: 'PBs' },
- { name: 'petabits/sec', id: 'Pbits' },
+ { name: 'packets/sec', id: DataRateFormats.PacketsPerSec },
+ { name: 'bytes/sec(IEC)', id: DataRateFormats.BytesPerSecIEC },
+ { name: 'bytes/sec(SI)', id: DataRateFormats.BytesPerSecSI },
+ { name: 'bits/sec(IEC)', id: DataRateFormats.BitsPerSecIEC },
+ { name: 'bits/sec(SI)', id: DataRateFormats.BitsPerSecSI },
+ { name: 'kibibytes/sec', id: DataRateFormats.KibiBytesPerSec },
+ { name: 'kibibits/sec', id: DataRateFormats.KibiBitsPerSec },
+ { name: 'kilobytes/sec', id: DataRateFormats.KiloBytesPerSec },
+ { name: 'kilobits/sec', id: DataRateFormats.KiloBitsPerSec },
+ { name: 'mebibytes/sec', id: DataRateFormats.MebiBytesPerSec },
+ { name: 'mebibits/sec', id: DataRateFormats.MebiBitsPerSec },
+ { name: 'megabytes/sec', id: DataRateFormats.MegaBytesPerSec },
+ { name: 'megabits/sec', id: DataRateFormats.MegaBitsPerSec },
+ { name: 'gibibytes/sec', id: DataRateFormats.GibiBytesPerSec },
+ { name: 'gibibits/sec', id: DataRateFormats.GibiBitsPerSec },
+ { name: 'gigabytes/sec', id: DataRateFormats.GigaBytesPerSec },
+ { name: 'gigabits/sec', id: DataRateFormats.GigaBitsPerSec },
+ { name: 'tebibytes/sec', id: DataRateFormats.TebiBytesPerSec },
+ { name: 'tebibits/sec', id: DataRateFormats.TebiBitsPerSec },
+ { name: 'terabytes/sec', id: DataRateFormats.TeraBytesPerSec },
+ { name: 'terabits/sec', id: DataRateFormats.TeraBitsPerSec },
+ { name: 'pebibytes/sec', id: DataRateFormats.PebiBytesPerSec },
+ { name: 'pebibits/sec', id: DataRateFormats.PebiBitsPerSec },
+ { name: 'petabytes/sec', id: DataRateFormats.PetaBytesPerSec },
+ { name: 'petabits/sec', id: DataRateFormats.PetaBitsPerSec },
],
},
{
- name: 'Hash rate',
+ name: CategoryNames.HashRate,
formats: [
- { name: 'hashes/sec', id: 'Hs' },
- { name: 'kilohashes/sec', id: 'KHs' },
- { name: 'megahashes/sec', id: 'MHs' },
- { name: 'gigahashes/sec', id: 'GHs' },
- { name: 'terahashes/sec', id: 'THs' },
- { name: 'petahashes/sec', id: 'PHs' },
- { name: 'exahashes/sec', id: 'EHs' },
+ { name: 'hashes/sec', id: HashRateFormats.HashesPerSec },
+ { name: 'kilohashes/sec', id: HashRateFormats.KiloHashesPerSec },
+ { name: 'megahashes/sec', id: HashRateFormats.MegaHashesPerSec },
+ { name: 'gigahashes/sec', id: HashRateFormats.GigaHashesPerSec },
+ { name: 'terahashes/sec', id: HashRateFormats.TeraHashesPerSec },
+ { name: 'petahashes/sec', id: HashRateFormats.PetaHashesPerSec },
+ { name: 'exahashes/sec', id: HashRateFormats.ExaHashesPerSec },
],
},
{
- name: 'Misc',
+ name: CategoryNames.Miscellaneous,
formats: [
- { name: 'none', id: 'none' },
- { name: 'String', id: 'string' },
- { name: 'short', id: 'short' },
- { name: 'Percent (0-100)', id: 'percent' },
- { name: 'Percent (0.0-1.0)', id: 'percentunit' },
- { name: 'Humidity (%H)', id: 'humidity' },
- { name: 'Decibel', id: 'dB' },
- { name: 'Hexadecimal (0x)', id: 'hex0x' },
- { name: 'Hexadecimal', id: 'hex' },
- { name: 'Scientific notation', id: 'sci' },
- { name: 'Locale format', id: 'locale' },
- { name: 'Pixels', id: 'pixel' },
+ { name: 'none', id: MiscellaneousFormats.None },
+ { name: 'String', id: MiscellaneousFormats.String },
+ { name: 'short', id: MiscellaneousFormats.Short },
+ { name: 'Percent (0-100)', id: MiscellaneousFormats.Percent },
+ { name: 'Percent (0.0-1.0)', id: MiscellaneousFormats.PercentUnit },
+ { name: 'Humidity (%H)', id: MiscellaneousFormats.Humidity },
+ { name: 'Decibel', id: MiscellaneousFormats.Decibel },
+ { name: 'Hexadecimal (0x)', id: MiscellaneousFormats.Hexadecimal0x },
+ { name: 'Hexadecimal', id: MiscellaneousFormats.Hexadecimal },
+ { name: 'Scientific notation', id: MiscellaneousFormats.ScientificNotation },
+ { name: 'Locale format', id: MiscellaneousFormats.LocaleFormat },
+ { name: 'Pixels', id: MiscellaneousFormats.Pixels },
],
},
{
- name: 'Acceleration',
+ name: CategoryNames.Acceleration,
formats: [
- { name: 'Meters/sec²', id: 'accMS2' },
- { name: 'Feet/sec²', id: 'accFS2' },
- { name: 'G unit', id: 'accG' },
+ { name: 'Meters/sec²', id: AccelerationFormats.MetersPerSecondSquared },
+ { name: 'Feet/sec²', id: AccelerationFormats.FeetPerSecondSquared },
+ { name: 'G unit', id: AccelerationFormats.GUnit },
],
},
{
- name: 'Angle',
+ name: CategoryNames.Angle,
formats: [
- { name: 'Degrees (°)', id: 'degree' },
- { name: 'Radians', id: 'radian' },
- { name: 'Gradian', id: 'grad' },
- { name: 'Arc Minutes', id: 'arcmin' },
- { name: 'Arc Seconds', id: 'arcsec' },
+ { name: 'Degrees (°)', id: AngularFormats.Degree },
+ { name: 'Radians', id: AngularFormats.Radian },
+ { name: 'Gradian', id: AngularFormats.Gradian },
+ { name: 'Arc Minutes', id: AngularFormats.ArcMinute },
+ { name: 'Arc Seconds', id: AngularFormats.ArcSecond },
],
},
{
- name: 'Area',
+ name: CategoryNames.Area,
formats: [
- { name: 'Square Meters (m²)', id: 'areaM2' },
- { name: 'Square Feet (ft²)', id: 'areaF2' },
- { name: 'Square Miles (mi²)', id: 'areaMI2' },
+ { name: 'Square Meters (m²)', id: AreaFormats.SquareMeters },
+ { name: 'Square Feet (ft²)', id: AreaFormats.SquareFeet },
+ { name: 'Square Miles (mi²)', id: AreaFormats.SquareMiles },
],
},
{
- name: 'Computation',
+ name: CategoryNames.Computation,
formats: [
- { name: 'FLOP/s', id: 'flops' },
- { name: 'MFLOP/s', id: 'mflops' },
- { name: 'GFLOP/s', id: 'gflops' },
- { name: 'TFLOP/s', id: 'tflops' },
- { name: 'PFLOP/s', id: 'pflops' },
- { name: 'EFLOP/s', id: 'eflops' },
- { name: 'ZFLOP/s', id: 'zflops' },
- { name: 'YFLOP/s', id: 'yflops' },
+ { name: 'FLOP/s', id: FlopsFormats.FLOPs },
+ { name: 'MFLOP/s', id: FlopsFormats.MFLOPs },
+ { name: 'GFLOP/s', id: FlopsFormats.GFLOPs },
+ { name: 'TFLOP/s', id: FlopsFormats.TFLOPs },
+ { name: 'PFLOP/s', id: FlopsFormats.PFLOPs },
+ { name: 'EFLOP/s', id: FlopsFormats.EFLOPs },
+ { name: 'ZFLOP/s', id: FlopsFormats.ZFLOPs },
+ { name: 'YFLOP/s', id: FlopsFormats.YFLOPs },
],
},
{
- name: 'Concentration',
+ name: CategoryNames.Concentration,
formats: [
- { name: 'parts-per-million (ppm)', id: 'ppm' },
- { name: 'parts-per-billion (ppb)', id: 'conppb' },
- { name: 'nanogram per cubic meter (ng/m³)', id: 'conngm3' },
- { name: 'nanogram per normal cubic meter (ng/Nm³)', id: 'conngNm3' },
- { name: 'microgram per cubic meter (μg/m³)', id: 'conμgm3' },
- { name: 'microgram per normal cubic meter (μg/Nm³)', id: 'conμgNm3' },
- { name: 'milligram per cubic meter (mg/m³)', id: 'conmgm3' },
- { name: 'milligram per normal cubic meter (mg/Nm³)', id: 'conmgNm3' },
- { name: 'gram per cubic meter (g/m³)', id: 'congm3' },
- { name: 'gram per normal cubic meter (g/Nm³)', id: 'congNm3' },
- { name: 'milligrams per decilitre (mg/dL)', id: 'conmgdL' },
- { name: 'millimoles per litre (mmol/L)', id: 'conmmolL' },
+ { name: 'parts-per-million (ppm)', id: ConcentrationFormats.PPM },
+ { name: 'parts-per-billion (ppb)', id: ConcentrationFormats.PPB },
+ { name: 'nanogram per cubic meter (ng/m³)', id: ConcentrationFormats.NgM3 },
+ {
+ name: 'nanogram per normal cubic meter (ng/Nm³)',
+ id: ConcentrationFormats.NgNM3,
+ },
+ { name: 'microgram per cubic meter (μg/m³)', id: ConcentrationFormats.UgM3 },
+ {
+ name: 'microgram per normal cubic meter (μg/Nm³)',
+ id: ConcentrationFormats.UgNM3,
+ },
+ { name: 'milligram per cubic meter (mg/m³)', id: ConcentrationFormats.MgM3 },
+ {
+ name: 'milligram per normal cubic meter (mg/Nm³)',
+ id: ConcentrationFormats.MgNM3,
+ },
+ { name: 'gram per cubic meter (g/m³)', id: ConcentrationFormats.GM3 },
+ {
+ name: 'gram per normal cubic meter (g/Nm³)',
+ id: ConcentrationFormats.GNM3,
+ },
+ { name: 'milligrams per decilitre (mg/dL)', id: ConcentrationFormats.MgDL },
+ { name: 'millimoles per litre (mmol/L)', id: ConcentrationFormats.MmolL },
],
},
{
- name: 'Currency',
+ name: CategoryNames.Currency,
formats: [
- { name: 'Dollars ($)', id: 'currencyUSD' },
- { name: 'Pounds (£)', id: 'currencyGBP' },
- { name: 'Euro (€)', id: 'currencyEUR' },
- { name: 'Yen (¥)', id: 'currencyJPY' },
- { name: 'Rubles (₽)', id: 'currencyRUB' },
- { name: 'Hryvnias (₴)', id: 'currencyUAH' },
- { name: 'Real (R$)', id: 'currencyBRL' },
- { name: 'Danish Krone (kr)', id: 'currencyDKK' },
- { name: 'Icelandic Króna (kr)', id: 'currencyISK' },
- { name: 'Norwegian Krone (kr)', id: 'currencyNOK' },
- { name: 'Swedish Krona (kr)', id: 'currencySEK' },
- { name: 'Czech koruna (czk)', id: 'currencyCZK' },
- { name: 'Swiss franc (CHF)', id: 'currencyCHF' },
- { name: 'Polish Złoty (PLN)', id: 'currencyPLN' },
- { name: 'Bitcoin (฿)', id: 'currencyBTC' },
- { name: 'Milli Bitcoin (฿)', id: 'currencymBTC' },
- { name: 'Micro Bitcoin (฿)', id: 'currencyμBTC' },
- { name: 'South African Rand (R)', id: 'currencyZAR' },
- { name: 'Indian Rupee (₹)', id: 'currencyINR' },
- { name: 'South Korean Won (₩)', id: 'currencyKRW' },
- { name: 'Indonesian Rupiah (Rp)', id: 'currencyIDR' },
- { name: 'Philippine Peso (PHP)', id: 'currencyPHP' },
- { name: 'Vietnamese Dong (VND)', id: 'currencyVND' },
+ { name: 'Dollars ($)', id: CurrencyFormats.USD },
+ { name: 'Pounds (£)', id: CurrencyFormats.GBP },
+ { name: 'Euro (€)', id: CurrencyFormats.EUR },
+ { name: 'Yen (¥)', id: CurrencyFormats.JPY },
+ { name: 'Rubles (₽)', id: CurrencyFormats.RUB },
+ { name: 'Hryvnias (₴)', id: CurrencyFormats.UAH },
+ { name: 'Real (R$)', id: CurrencyFormats.BRL },
+ { name: 'Danish Krone (kr)', id: CurrencyFormats.DKK },
+ { name: 'Icelandic Króna (kr)', id: CurrencyFormats.ISK },
+ { name: 'Norwegian Krone (kr)', id: CurrencyFormats.NOK },
+ { name: 'Swedish Krona (kr)', id: CurrencyFormats.SEK },
+ { name: 'Czech koruna (czk)', id: CurrencyFormats.CZK },
+ { name: 'Swiss franc (CHF)', id: CurrencyFormats.CHF },
+ { name: 'Polish Złoty (PLN)', id: CurrencyFormats.PLN },
+ { name: 'Bitcoin (฿)', id: CurrencyFormats.BTC },
+ { name: 'Milli Bitcoin (฿)', id: CurrencyFormats.MBTC },
+ { name: 'Micro Bitcoin (฿)', id: CurrencyFormats.UBTC },
+ { name: 'South African Rand (R)', id: CurrencyFormats.ZAR },
+ { name: 'Indian Rupee (₹)', id: CurrencyFormats.INR },
+ { name: 'South Korean Won (₩)', id: CurrencyFormats.KRW },
+ { name: 'Indonesian Rupiah (Rp)', id: CurrencyFormats.IDR },
+ { name: 'Philippine Peso (PHP)', id: CurrencyFormats.PHP },
+ { name: 'Vietnamese Dong (VND)', id: CurrencyFormats.VND },
],
},
-
{
- name: 'Date & time',
+ name: CategoryNames.Datetime,
formats: [
- { name: 'Datetime ISO', id: 'dateTimeAsIso' },
+ { name: 'Datetime ISO', id: DatetimeFormats.ISO },
{
name: 'Datetime ISO (No date if today)',
- id: 'dateTimeAsIsoNoDateIfToday',
+ id: DatetimeFormats.ISONoDateIfToday,
+ },
+ { name: 'Datetime US', id: DatetimeFormats.US },
+ {
+ name: 'Datetime US (No date if today)',
+ id: DatetimeFormats.USNoDateIfToday,
},
- { name: 'Datetime US', id: 'dateTimeAsUS' },
- { name: 'Datetime US (No date if today)', id: 'dateTimeAsUSNoDateIfToday' },
- { name: 'Datetime local', id: 'dateTimeAsLocal' },
+ { name: 'Datetime local', id: DatetimeFormats.Local },
{
name: 'Datetime local (No date if today)',
- id: 'dateTimeAsLocalNoDateIfToday',
+ id: DatetimeFormats.LocalNoDateIfToday,
},
- { name: 'Datetime default', id: 'dateTimeAsSystem' },
- { name: 'From Now', id: 'dateTimeFromNow' },
+ { name: 'Datetime default', id: DatetimeFormats.System },
+ { name: 'From Now', id: DatetimeFormats.FromNow },
],
},
{
- name: 'Energy',
+ name: CategoryNames.Energy,
formats: [
- { name: 'Watt (W)', id: 'watt' },
- { name: 'Kilowatt (kW)', id: 'kwatt' },
- { name: 'Megawatt (MW)', id: 'megwatt' },
- { name: 'Gigawatt (GW)', id: 'gwatt' },
- { name: 'Milliwatt (mW)', id: 'mwatt' },
- { name: 'Watt per square meter (W/m²)', id: 'Wm2' },
- { name: 'Volt-Ampere (VA)', id: 'voltamp' },
- { name: 'Kilovolt-Ampere (kVA)', id: 'kvoltamp' },
- { name: 'Volt-Ampere reactive (VAr)', id: 'voltampreact' },
- { name: 'Kilovolt-Ampere reactive (kVAr)', id: 'kvoltampreact' },
- { name: 'Watt-hour (Wh)', id: 'watth' },
- { name: 'Watt-hour per Kilogram (Wh/kg)', id: 'watthperkg' },
- { name: 'Kilowatt-hour (kWh)', id: 'kwatth' },
- { name: 'Kilowatt-min (kWm)', id: 'kwattm' },
- { name: 'Ampere-hour (Ah)', id: 'amph' },
- { name: 'Kiloampere-hour (kAh)', id: 'kamph' },
- { name: 'Milliampere-hour (mAh)', id: 'mamph' },
- { name: 'Joule (J)', id: 'joule' },
- { name: 'Electron volt (eV)', id: 'ev' },
- { name: 'Ampere (A)', id: 'amp' },
- { name: 'Kiloampere (kA)', id: 'kamp' },
- { name: 'Milliampere (mA)', id: 'mamp' },
- { name: 'Volt (V)', id: 'volt' },
- { name: 'Kilovolt (kV)', id: 'kvolt' },
- { name: 'Millivolt (mV)', id: 'mvolt' },
- { name: 'Decibel-milliwatt (dBm)', id: 'dBm' },
- { name: 'Ohm (Ω)', id: 'ohm' },
- { name: 'Kiloohm (kΩ)', id: 'kohm' },
- { name: 'Megaohm (MΩ)', id: 'Mohm' },
- { name: 'Farad (F)', id: 'farad' },
- { name: 'Microfarad (µF)', id: 'µfarad' },
- { name: 'Nanofarad (nF)', id: 'nfarad' },
- { name: 'Picofarad (pF)', id: 'pfarad' },
- { name: 'Femtofarad (fF)', id: 'ffarad' },
- { name: 'Henry (H)', id: 'henry' },
- { name: 'Millihenry (mH)', id: 'mhenry' },
- { name: 'Microhenry (µH)', id: 'µhenry' },
- { name: 'Lumens (Lm)', id: 'lumens' },
+ { name: 'Watt (W)', id: PowerElectricalFormats.WATT },
+ { name: 'Kilowatt (kW)', id: PowerElectricalFormats.KWATT },
+ { name: 'Megawatt (MW)', id: PowerElectricalFormats.MEGWATT },
+ { name: 'Gigawatt (GW)', id: PowerElectricalFormats.GWATT },
+ { name: 'Milliwatt (mW)', id: PowerElectricalFormats.MWATT },
+ { name: 'Watt per square meter (W/m²)', id: PowerElectricalFormats.WM2 },
+ { name: 'Volt-Ampere (VA)', id: PowerElectricalFormats.VOLTAMP },
+ { name: 'Kilovolt-Ampere (kVA)', id: PowerElectricalFormats.KVOLTAMP },
+ {
+ name: 'Volt-Ampere reactive (VAr)',
+ id: PowerElectricalFormats.VOLTAMPREACT,
+ },
+ {
+ name: 'Kilovolt-Ampere reactive (kVAr)',
+ id: PowerElectricalFormats.KVOLTAMPREACT,
+ },
+ { name: 'Watt-hour (Wh)', id: PowerElectricalFormats.WATTH },
+ {
+ name: 'Watt-hour per Kilogram (Wh/kg)',
+ id: PowerElectricalFormats.WATTHPERKG,
+ },
+ { name: 'Kilowatt-hour (kWh)', id: PowerElectricalFormats.KWATTH },
+ { name: 'Kilowatt-min (kWm)', id: PowerElectricalFormats.KWATTM },
+ { name: 'Ampere-hour (Ah)', id: PowerElectricalFormats.AMPH },
+ { name: 'Kiloampere-hour (kAh)', id: PowerElectricalFormats.KAMPH },
+ { name: 'Milliampere-hour (mAh)', id: PowerElectricalFormats.MAMPH },
+ { name: 'Joule (J)', id: PowerElectricalFormats.JOULE },
+ { name: 'Electron volt (eV)', id: PowerElectricalFormats.EV },
+ { name: 'Ampere (A)', id: PowerElectricalFormats.AMP },
+ { name: 'Kiloampere (kA)', id: PowerElectricalFormats.KAMP },
+ { name: 'Milliampere (mA)', id: PowerElectricalFormats.MAMP },
+ { name: 'Volt (V)', id: PowerElectricalFormats.VOLT },
+ { name: 'Kilovolt (kV)', id: PowerElectricalFormats.KVOLT },
+ { name: 'Millivolt (mV)', id: PowerElectricalFormats.MVOLT },
+ { name: 'Decibel-milliwatt (dBm)', id: PowerElectricalFormats.DBM },
+ { name: 'Ohm (Ω)', id: PowerElectricalFormats.OHM },
+ { name: 'Kiloohm (kΩ)', id: PowerElectricalFormats.KOHM },
+ { name: 'Megaohm (MΩ)', id: PowerElectricalFormats.MOHM },
+ { name: 'Farad (F)', id: PowerElectricalFormats.FARAD },
+ { name: 'Microfarad (µF)', id: PowerElectricalFormats.µFARAD },
+ { name: 'Nanofarad (nF)', id: PowerElectricalFormats.NFARAD },
+ { name: 'Picofarad (pF)', id: PowerElectricalFormats.PFARAD },
+ { name: 'Femtofarad (fF)', id: PowerElectricalFormats.FFARAD },
+ { name: 'Henry (H)', id: PowerElectricalFormats.HENRY },
+ { name: 'Millihenry (mH)', id: PowerElectricalFormats.MHENRY },
+ { name: 'Microhenry (µH)', id: PowerElectricalFormats.µHENRY },
+ { name: 'Lumens (Lm)', id: PowerElectricalFormats.LUMENS },
],
},
{
- name: 'Flow',
+ name: CategoryNames.Flow,
formats: [
- { name: 'Gallons/min (gpm)', id: 'flowgpm' },
- { name: 'Cubic meters/sec (cms)', id: 'flowcms' },
- { name: 'Cubic feet/sec (cfs)', id: 'flowcfs' },
- { name: 'Cubic feet/min (cfm)', id: 'flowcfm' },
- { name: 'Litre/hour', id: 'litreh' },
- { name: 'Litre/min (L/min)', id: 'flowlpm' },
- { name: 'milliLitre/min (mL/min)', id: 'flowmlpm' },
- { name: 'Lux (lx)', id: 'lux' },
+ { name: 'Gallons/min (gpm)', id: FlowFormats.FLOWGPM },
+ { name: 'Cubic meters/sec (cms)', id: FlowFormats.FLOWCMS },
+ { name: 'Cubic feet/sec (cfs)', id: FlowFormats.FLOWCFS },
+ { name: 'Cubic feet/min (cfm)', id: FlowFormats.FLOWCFM },
+ { name: 'Litre/hour', id: FlowFormats.LITREH },
+ { name: 'Litre/min (L/min)', id: FlowFormats.FLOWLPM },
+ { name: 'milliLitre/min (mL/min)', id: FlowFormats.FLOWMLPM },
+ { name: 'Lux (lx)', id: FlowFormats.LUX },
],
},
{
- name: 'Force',
+ name: CategoryNames.Force,
formats: [
- { name: 'Newton-meters (Nm)', id: 'forceNm' },
- { name: 'Kilonewton-meters (kNm)', id: 'forcekNm' },
- { name: 'Newtons (N)', id: 'forceN' },
- { name: 'Kilonewtons (kN)', id: 'forcekN' },
+ { name: 'Newton-meters (Nm)', id: ForceFormats.FORCENM },
+ { name: 'Kilonewton-meters (kNm)', id: ForceFormats.FORCEKNM },
+ { name: 'Newtons (N)', id: ForceFormats.FORCEN },
+ { name: 'Kilonewtons (kN)', id: ForceFormats.FORCEKN },
],
},
{
- name: 'Mass',
+ name: CategoryNames.Mass,
formats: [
- { name: 'milligram (mg)', id: 'massmg' },
- { name: 'gram (g)', id: 'massg' },
- { name: 'pound (lb)', id: 'masslb' },
- { name: 'kilogram (kg)', id: 'masskg' },
- { name: 'metric ton (t)', id: 'masst' },
+ { name: 'milligram (mg)', id: MassFormats.MASSMG },
+ { name: 'gram (g)', id: MassFormats.MASSG },
+ { name: 'pound (lb)', id: MassFormats.MASSLB },
+ { name: 'kilogram (kg)', id: MassFormats.MASSKG },
+ { name: 'metric ton (t)', id: MassFormats.MASST },
],
},
{
- name: 'Length',
+ name: CategoryNames.Length,
formats: [
- { name: 'millimeter (mm)', id: 'lengthmm' },
- { name: 'inch (in)', id: 'lengthin' },
- { name: 'feet (ft)', id: 'lengthft' },
- { name: 'meter (m)', id: 'lengthm' },
- { name: 'kilometer (km)', id: 'lengthkm' },
- { name: 'mile (mi)', id: 'lengthmi' },
+ { name: 'millimeter (mm)', id: LengthFormats.LENGTHMM },
+ { name: 'inch (in)', id: LengthFormats.LENGTHIN },
+ { name: 'feet (ft)', id: LengthFormats.LENGTHFT },
+ { name: 'meter (m)', id: LengthFormats.LENGTHM },
+ { name: 'kilometer (km)', id: LengthFormats.LENGTHKM },
+ { name: 'mile (mi)', id: LengthFormats.LENGTHMI },
],
},
{
- name: 'Pressure',
+ name: CategoryNames.Pressure,
formats: [
- { name: 'Millibars', id: 'pressurembar' },
- { name: 'Bars', id: 'pressurebar' },
- { name: 'Kilobars', id: 'pressurekbar' },
- { name: 'Pascals', id: 'pressurepa' },
- { name: 'Hectopascals', id: 'pressurehpa' },
- { name: 'Kilopascals', id: 'pressurekpa' },
- { name: 'Inches of mercury', id: 'pressurehg' },
- { name: 'PSI', id: 'pressurepsi' },
+ { name: 'Millibars', id: PressureFormats.PRESSUREMBAR },
+ { name: 'Bars', id: PressureFormats.PRESSUREBAR },
+ { name: 'Kilobars', id: PressureFormats.PRESSUREKBAR },
+ { name: 'Pascals', id: PressureFormats.PRESSUREPA },
+ { name: 'Hectopascals', id: PressureFormats.PRESSUREHPA },
+ { name: 'Kilopascals', id: PressureFormats.PRESSUREKPA },
+ { name: 'Inches of mercury', id: PressureFormats.PRESSUREHG },
+ { name: 'PSI', id: PressureFormats.PRESSUREPSI },
],
},
{
- name: 'Radiation',
+ name: CategoryNames.Radiation,
formats: [
- { name: 'Becquerel (Bq)', id: 'radbq' },
- { name: 'curie (Ci)', id: 'radci' },
- { name: 'Gray (Gy)', id: 'radgy' },
- { name: 'rad', id: 'radrad' },
- { name: 'Sievert (Sv)', id: 'radsv' },
- { name: 'milliSievert (mSv)', id: 'radmsv' },
- { name: 'microSievert (µSv)', id: 'radusv' },
- { name: 'rem', id: 'radrem' },
- { name: 'Exposure (C/kg)', id: 'radexpckg' },
- { name: 'roentgen (R)', id: 'radr' },
- { name: 'Sievert/hour (Sv/h)', id: 'radsvh' },
- { name: 'milliSievert/hour (mSv/h)', id: 'radmsvh' },
- { name: 'microSievert/hour (µSv/h)', id: 'radusvh' },
+ { name: 'Becquerel (Bq)', id: RadiationFormats.RADBQ },
+ { name: 'curie (Ci)', id: RadiationFormats.RADCI },
+ { name: 'Gray (Gy)', id: RadiationFormats.RADGY },
+ { name: 'rad', id: RadiationFormats.RADRAD },
+ { name: 'Sievert (Sv)', id: RadiationFormats.RADSV },
+ { name: 'milliSievert (mSv)', id: RadiationFormats.RADMSV },
+ { name: 'microSievert (µSv)', id: RadiationFormats.RADUSV },
+ { name: 'rem', id: RadiationFormats.RADREM },
+ { name: 'Exposure (C/kg)', id: RadiationFormats.RADEXPCKG },
+ { name: 'roentgen (R)', id: RadiationFormats.RADR },
+ { name: 'Sievert/hour (Sv/h)', id: RadiationFormats.RADSVH },
+ { name: 'milliSievert/hour (mSv/h)', id: RadiationFormats.RADMSVH },
+ { name: 'microSievert/hour (µSv/h)', id: RadiationFormats.RADUSVH },
],
},
{
- name: 'Rotational Speed',
+ name: CategoryNames.RotationSpeed,
formats: [
- { name: 'Revolutions per minute (rpm)', id: 'rotrpm' },
- { name: 'Hertz (Hz)', id: 'rothz' },
- { name: 'Radians per second (rad/s)', id: 'rotrads' },
- { name: 'Degrees per second (°/s)', id: 'rotdegs' },
+ { name: 'Revolutions per minute (rpm)', id: RotationSpeedFormats.ROTRPM },
+ { name: 'Hertz (Hz)', id: RotationSpeedFormats.ROTHZ },
+ { name: 'Radians per second (rad/s)', id: RotationSpeedFormats.ROTRADS },
+ { name: 'Degrees per second (°/s)', id: RotationSpeedFormats.ROTDEGS },
],
},
{
- name: 'Temperature',
+ name: CategoryNames.Temperature,
formats: [
- { name: 'Celsius (°C)', id: 'celsius' },
- { name: 'Fahrenheit (°F)', id: 'fahrenheit' },
- { name: 'Kelvin (K)', id: 'kelvin' },
+ { name: 'Celsius (°C)', id: TemperatureFormats.CELSIUS },
+ { name: 'Fahrenheit (°F)', id: TemperatureFormats.FAHRENHEIT },
+ { name: 'Kelvin (K)', id: TemperatureFormats.KELVIN },
],
},
{
- name: 'Velocity',
+ name: CategoryNames.Velocity,
formats: [
- { name: 'meters/second (m/s)', id: 'velocityms' },
- { name: 'kilometers/hour (km/h)', id: 'velocitykmh' },
- { name: 'miles/hour (mph)', id: 'velocitymph' },
- { name: 'knot (kn)', id: 'velocityknot' },
+ { name: 'meters/second (m/s)', id: VelocityFormats.METERS_PER_SECOND },
+ { name: 'kilometers/hour (km/h)', id: VelocityFormats.KILOMETERS_PER_HOUR },
+ { name: 'miles/hour (mph)', id: VelocityFormats.MILES_PER_HOUR },
+ { name: 'knot (kn)', id: VelocityFormats.KNOT },
],
},
{
- name: 'Volume',
+ name: CategoryNames.Volume,
formats: [
- { name: 'millilitre (mL)', id: 'mlitre' },
- { name: 'litre (L)', id: 'litre' },
- { name: 'cubic meter', id: 'm3' },
- { name: 'Normal cubic meter', id: 'Nm3' },
- { name: 'cubic decimeter', id: 'dm3' },
- { name: 'gallons', id: 'gallons' },
+ { name: 'millilitre (mL)', id: VolumeFormats.MILLILITRE },
+ { name: 'litre (L)', id: VolumeFormats.LITRE },
+ { name: 'cubic meter', id: VolumeFormats.CUBIC_METER },
+ { name: 'Normal cubic meter', id: VolumeFormats.NORMAL_CUBIC_METER },
+ { name: 'cubic decimeter', id: VolumeFormats.CUBIC_DECIMETER },
+ { name: 'gallons', id: VolumeFormats.GALLONS },
],
},
{
- name: 'Boolean',
+ name: CategoryNames.Boolean,
formats: [
- { name: 'True / False', id: 'bool' },
- { name: 'Yes / No', id: 'bool_yes_no' },
- { name: 'On / Off', id: 'bool_on_off' },
+ { name: 'True / False', id: BooleanFormats.TRUE_FALSE },
+ { name: 'Yes / No', id: BooleanFormats.YES_NO },
+ { name: 'On / Off', id: BooleanFormats.ON_OFF },
],
},
];
diff --git a/frontend/src/container/NewWidget/RightContainer/types.ts b/frontend/src/container/NewWidget/RightContainer/types.ts
new file mode 100644
index 0000000000..36d4d106ac
--- /dev/null
+++ b/frontend/src/container/NewWidget/RightContainer/types.ts
@@ -0,0 +1,364 @@
+export enum CategoryNames {
+ Time = 'Time',
+ Throughput = 'Throughput',
+ Data = 'Data',
+ DataRate = 'DataRate',
+ HashRate = 'HashRate',
+ Miscellaneous = 'Miscellaneous',
+ Acceleration = 'Acceleration',
+ Angular = 'Angular',
+ Area = 'Area',
+ Flops = 'Flops',
+ Concentration = 'Concentration',
+ Currency = 'Currency',
+ Datetime = 'Datetime',
+ PowerElectrical = 'PowerElectrical',
+ Flow = 'Flow',
+ Force = 'Force',
+ Mass = 'Mass',
+ Length = 'Length',
+ Pressure = 'Pressure',
+ Radiation = 'Radiation',
+ RotationSpeed = 'RotationSpeed',
+ Temperature = 'Temperature',
+ Velocity = 'Velocity',
+ Volume = 'Volume',
+ Boolean = 'Boolean',
+ Angle = 'Angle',
+ Computation = 'Computation',
+ Energy = 'Energy',
+}
+
+export enum TimeFormats {
+ Hertz = 'hertz',
+ Nanoseconds = 'ns',
+ Microseconds = 'µs',
+ Milliseconds = 'ms',
+ Seconds = 's',
+ Minutes = 'm',
+ Hours = 'h',
+ Days = 'd',
+ DurationMs = 'dtdurationms',
+ DurationS = 'dtdurations',
+ DurationHms = 'dthms',
+ DurationDhms = 'dtdhms',
+ Timeticks = 'timeticks',
+ ClockMs = 'clockms',
+ ClockS = 'clocks',
+}
+
+export enum ThroughputFormats {
+ CountsPerSec = 'cps',
+ OpsPerSec = 'ops',
+ RequestsPerSec = 'reqps',
+ ReadsPerSec = 'rps',
+ WritesPerSec = 'wps',
+ IOOpsPerSec = 'iops',
+ CountsPerMin = 'cpm',
+ OpsPerMin = 'opm',
+ ReadsPerMin = 'rpm',
+ WritesPerMin = 'wpm',
+}
+
+export enum DataFormats {
+ BytesIEC = 'bytes',
+ BytesSI = 'decbytes',
+ BitsIEC = 'bits',
+ BitsSI = 'decbits',
+ KibiBytes = 'kbytes',
+ KiloBytes = 'deckbytes',
+ MebiBytes = 'mbytes',
+ MegaBytes = 'decmbytes',
+ GibiBytes = 'gbytes',
+ GigaBytes = 'decgbytes',
+ TebiBytes = 'tbytes',
+ TeraBytes = 'dectbytes',
+ PebiBytes = 'pbytes',
+ PetaBytes = 'decpbytes',
+}
+
+export enum DataRateFormats {
+ PacketsPerSec = 'pps',
+ BytesPerSecIEC = 'binBps',
+ BytesPerSecSI = 'Bps',
+ BitsPerSecIEC = 'binbps',
+ BitsPerSecSI = 'bps',
+ KibiBytesPerSec = 'KiBs',
+ KibiBitsPerSec = 'Kibits',
+ KiloBytesPerSec = 'KBs',
+ KiloBitsPerSec = 'Kbits',
+ MebiBytesPerSec = 'MiBs',
+ MebiBitsPerSec = 'Mibits',
+ MegaBytesPerSec = 'MBs',
+ MegaBitsPerSec = 'Mbits',
+ GibiBytesPerSec = 'GiBs',
+ GibiBitsPerSec = 'Gibits',
+ GigaBytesPerSec = 'GBs',
+ GigaBitsPerSec = 'Gbits',
+ TebiBytesPerSec = 'TiBs',
+ TebiBitsPerSec = 'Tibits',
+ TeraBytesPerSec = 'TBs',
+ TeraBitsPerSec = 'Tbits',
+ PebiBytesPerSec = 'PiBs',
+ PebiBitsPerSec = 'Pibits',
+ PetaBytesPerSec = 'PBs',
+ PetaBitsPerSec = 'Pbits',
+}
+
+export enum HashRateFormats {
+ HashesPerSec = 'Hs',
+ KiloHashesPerSec = 'KHs',
+ MegaHashesPerSec = 'MHs',
+ GigaHashesPerSec = 'GHs',
+ TeraHashesPerSec = 'THs',
+ PetaHashesPerSec = 'PHs',
+ ExaHashesPerSec = 'EHs',
+}
+
+export enum MiscellaneousFormats {
+ None = 'none',
+ String = 'string',
+ Short = 'short',
+ Percent = 'percent',
+ PercentUnit = 'percentunit',
+ Humidity = 'humidity',
+ Decibel = 'dB',
+ Hexadecimal0x = 'hex0x',
+ Hexadecimal = 'hex',
+ ScientificNotation = 'sci',
+ LocaleFormat = 'locale',
+ Pixels = 'pixel',
+}
+
+export enum AccelerationFormats {
+ MetersPerSecondSquared = 'accMS2',
+ FeetPerSecondSquared = 'accFS2',
+ GUnit = 'accG',
+}
+
+export enum AngularFormats {
+ Degree = 'degree',
+ Radian = 'radian',
+ Gradian = 'grad',
+ ArcMinute = 'arcmin',
+ ArcSecond = 'arcsec',
+}
+
+export enum AreaFormats {
+ SquareMeters = 'areaM2',
+ SquareFeet = 'areaF2',
+ SquareMiles = 'areaMI2',
+}
+
+export enum FlopsFormats {
+ FLOPs = 'flops',
+ MFLOPs = 'mflops',
+ GFLOPs = 'gflops',
+ TFLOPs = 'tflops',
+ PFLOPs = 'pflops',
+ EFLOPs = 'eflops',
+ ZFLOPs = 'zflops',
+ YFLOPs = 'yflops',
+}
+
+export enum ConcentrationFormats {
+ PPM = 'ppm',
+ PPB = 'conppb',
+ NgM3 = 'conngm3',
+ NgNM3 = 'conngNm3',
+ UgM3 = 'conμgm3',
+ UgNM3 = 'conμgNm3',
+ MgM3 = 'conmgm3',
+ MgNM3 = 'conmgNm3',
+ GM3 = 'congm3',
+ GNM3 = 'congNm3',
+ MgDL = 'conmgdL',
+ MmolL = 'conmmolL',
+}
+
+export enum CurrencyFormats {
+ USD = 'currencyUSD',
+ GBP = 'currencyGBP',
+ EUR = 'currencyEUR',
+ JPY = 'currencyJPY',
+ RUB = 'currencyRUB',
+ UAH = 'currencyUAH',
+ BRL = 'currencyBRL',
+ DKK = 'currencyDKK',
+ ISK = 'currencyISK',
+ NOK = 'currencyNOK',
+ SEK = 'currencySEK',
+ CZK = 'currencyCZK',
+ CHF = 'currencyCHF',
+ PLN = 'currencyPLN',
+ BTC = 'currencyBTC',
+ MBTC = 'currencymBTC',
+ UBTC = 'currencyμBTC',
+ ZAR = 'currencyZAR',
+ INR = 'currencyINR',
+ KRW = 'currencyKRW',
+ IDR = 'currencyIDR',
+ PHP = 'currencyPHP',
+ VND = 'currencyVND',
+}
+
+export enum DatetimeFormats {
+ ISO = 'dateTimeAsIso',
+ ISONoDateIfToday = 'dateTimeAsIsoNoDateIfToday',
+ US = 'dateTimeAsUS',
+ USNoDateIfToday = 'dateTimeAsUSNoDateIfToday',
+ Local = 'dateTimeAsLocal',
+ LocalNoDateIfToday = 'dateTimeAsLocalNoDateIfToday',
+ System = 'dateTimeAsSystem',
+ FromNow = 'dateTimeFromNow',
+}
+
+export enum PowerElectricalFormats {
+ WATT = 'watt',
+ KWATT = 'kwatt',
+ MEGWATT = 'megwatt',
+ GWATT = 'gwatt',
+ MWATT = 'mwatt',
+ WM2 = 'Wm2',
+ VOLTAMP = 'voltamp',
+ KVOLTAMP = 'kvoltamp',
+ VOLTAMPREACT = 'voltampreact',
+ KVOLTAMPREACT = 'kvoltampreact',
+ WATTH = 'watth',
+ WATTHPERKG = 'watthperkg',
+ KWATTH = 'kwatth',
+ KWATTM = 'kwattm',
+ AMPH = 'amph',
+ KAMPH = 'kamph',
+ MAMPH = 'mamph',
+ JOULE = 'joule',
+ EV = 'ev',
+ AMP = 'amp',
+ KAMP = 'kamp',
+ MAMP = 'mamp',
+ VOLT = 'volt',
+ KVOLT = 'kvolt',
+ MVOLT = 'mvolt',
+ DBM = 'dBm',
+ OHM = 'ohm',
+ KOHM = 'kohm',
+ MOHM = 'Mohm',
+ FARAD = 'farad',
+ µFARAD = 'µfarad',
+ NFARAD = 'nfarad',
+ PFARAD = 'pfarad',
+ FFARAD = 'ffarad',
+ HENRY = 'henry',
+ MHENRY = 'mhenry',
+ µHENRY = 'µhenry',
+ LUMENS = 'lumens',
+}
+
+export enum FlowFormats {
+ FLOWGPM = 'flowgpm',
+ FLOWCMS = 'flowcms',
+ FLOWCFS = 'flowcfs',
+ FLOWCFM = 'flowcfm',
+ LITREH = 'litreh',
+ FLOWLPM = 'flowlpm',
+ FLOWMLPM = 'flowmlpm',
+ LUX = 'lux',
+}
+
+export enum ForceFormats {
+ FORCENM = 'forceNm',
+ FORCEKNM = 'forcekNm',
+ FORCEN = 'forceN',
+ FORCEKN = 'forcekN',
+}
+
+export enum MassFormats {
+ MASSMG = 'massmg',
+ MASSG = 'massg',
+ MASSLB = 'masslb',
+ MASSKG = 'masskg',
+ MASST = 'masst',
+}
+
+export enum LengthFormats {
+ LENGTHMM = 'lengthmm',
+ LENGTHIN = 'lengthin',
+ LENGTHFT = 'lengthft',
+ LENGTHM = 'lengthm',
+ LENGTHKM = 'lengthkm',
+ LENGTHMI = 'lengthmi',
+}
+
+export enum PressureFormats {
+ PRESSUREMBAR = 'pressurembar',
+ PRESSUREBAR = 'pressurebar',
+ PRESSUREKBAR = 'pressurekbar',
+ PRESSUREPA = 'pressurepa',
+ PRESSUREHPA = 'pressurehpa',
+ PRESSUREKPA = 'pressurekpa',
+ PRESSUREHG = 'pressurehg',
+ PRESSUREPSI = 'pressurepsi',
+}
+
+export enum RadiationFormats {
+ RADBQ = 'radbq',
+ RADCI = 'radci',
+ RADGY = 'radgy',
+ RADRAD = 'radrad',
+ RADSV = 'radsv',
+ RADMSV = 'radmsv',
+ RADUSV = 'radusv',
+ RADREM = 'radrem',
+ RADEXPCKG = 'radexpckg',
+ RADR = 'radr',
+ RADSVH = 'radsvh',
+ RADMSVH = 'radmsvh',
+ RADUSVH = 'radusvh',
+}
+
+export enum RotationSpeedFormats {
+ ROTRPM = 'rotrpm',
+ ROTHZ = 'rothz',
+ ROTRADS = 'rotrads',
+ ROTDEGS = 'rotdegs',
+}
+
+export enum TemperatureFormats {
+ CELSIUS = 'celsius',
+ FAHRENHEIT = 'fahrenheit',
+ KELVIN = 'kelvin',
+}
+
+export enum VelocityFormats {
+ METERS_PER_SECOND = 'velocityms',
+ KILOMETERS_PER_HOUR = 'velocitykmh',
+ MILES_PER_HOUR = 'velocitymph',
+ KNOT = 'velocityknot',
+}
+
+export enum VolumeFormats {
+ MILLILITRE = 'mlitre',
+ LITRE = 'litre',
+ CUBIC_METER = 'm3',
+ NORMAL_CUBIC_METER = 'Nm3',
+ CUBIC_DECIMETER = 'dm3',
+ GALLONS = 'gallons',
+}
+
+export enum BooleanFormats {
+ TRUE_FALSE = 'bool',
+ YES_NO = 'bool_yes_no',
+ ON_OFF = 'bool_on_off',
+}
+
+export type Format = {
+ name: string;
+ id: string;
+};
+
+export type Category = {
+ name: string;
+ formats: Format[];
+};
+
+export type DataTypeCategories = Category[];
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/BuilderUnits.tsx b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/BuilderUnits.tsx
new file mode 100644
index 0000000000..b60a530809
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/BuilderUnits.tsx
@@ -0,0 +1,48 @@
+import { Select, SelectProps, Space } from 'antd';
+import { getCategorySelectOptionByName } from 'container/NewWidget/RightContainer/alertFomatCategories';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+
+import { categoryToSupport } from './config';
+import { DefaultLabel, selectStyles } from './styles';
+import { IBuilderUnitsFilterProps } from './types';
+import { filterOption } from './utils';
+
+function BuilderUnitsFilter({
+ onChange,
+}: IBuilderUnitsFilterProps): JSX.Element {
+ const { currentQuery, handleOnUnitsChange } = useQueryBuilder();
+
+ const selectedValue = currentQuery?.unit;
+
+ const allOptions = categoryToSupport.map((category) => ({
+ label: category,
+ options: getCategorySelectOptionByName(category),
+ }));
+
+ const onChangeHandler: SelectProps['onChange'] = (value): void => {
+ if (onChange) {
+ onChange(value);
+ }
+
+ handleOnUnitsChange(value);
+ };
+
+ return (
+ <Space>
+ <DefaultLabel>Y-axis unit</DefaultLabel>
+ <Select
+ style={selectStyles}
+ onChange={onChangeHandler}
+ value={selectedValue}
+ options={allOptions}
+ allowClear
+ showSearch
+ optionFilterProp="label"
+ placeholder="Select unit"
+ filterOption={filterOption}
+ />
+ </Space>
+ );
+}
+
+export { BuilderUnitsFilter };
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/config.ts b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/config.ts
new file mode 100644
index 0000000000..244591c2c2
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/config.ts
@@ -0,0 +1,10 @@
+import { CategoryNames } from 'container/NewWidget/RightContainer/types';
+
+export const categoryToSupport = [
+ CategoryNames.Data,
+ CategoryNames.DataRate,
+ CategoryNames.Time,
+ CategoryNames.Throughput,
+ CategoryNames.Miscellaneous,
+ CategoryNames.Boolean,
+];
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/index.ts b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/index.ts
new file mode 100644
index 0000000000..977a301ca7
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/index.ts
@@ -0,0 +1 @@
+export { BuilderUnitsFilter } from './BuilderUnits';
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/styles.ts b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/styles.ts
new file mode 100644
index 0000000000..ddfba28930
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/styles.ts
@@ -0,0 +1,11 @@
+import styled from 'styled-components';
+
+export const selectStyles: React.CSSProperties = {
+ minWidth: '10rem',
+};
+
+export const DefaultLabel = styled.label`
+ display: inline-block;
+ font-size: 1rem;
+ line-height: 2rem;
+`;
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/types.ts b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/types.ts
new file mode 100644
index 0000000000..693dab7be6
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/types.ts
@@ -0,0 +1,3 @@
+export interface IBuilderUnitsFilterProps {
+ onChange?: (value: string) => void;
+}
diff --git a/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/utils.ts b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/utils.ts
new file mode 100644
index 0000000000..a3a2947608
--- /dev/null
+++ b/frontend/src/container/QueryBuilder/filters/BuilderUnitsFilter/utils.ts
@@ -0,0 +1,6 @@
+import { DefaultOptionType } from 'antd/es/select';
+
+export const filterOption = (
+ inputValue: string,
+ option: DefaultOptionType['options'][number],
+): boolean => option.label.toLowerCase().includes(inputValue.toLowerCase());
diff --git a/frontend/src/container/QueryBuilder/filters/index.ts b/frontend/src/container/QueryBuilder/filters/index.ts
index d15a242fde..5a7292e5b1 100644
--- a/frontend/src/container/QueryBuilder/filters/index.ts
+++ b/frontend/src/container/QueryBuilder/filters/index.ts
@@ -1,4 +1,5 @@
export { AggregatorFilter } from './AggregatorFilter';
+export { BuilderUnitsFilter } from './BuilderUnitsFilter';
export { GroupByFilter } from './GroupByFilter';
export { HavingFilter } from './HavingFilter';
export { OperatorsSelect } from './OperatorsSelect';
diff --git a/frontend/src/lib/newQueryBuilder/queryBuilderMappers/mapQueryDataFromApi.ts b/frontend/src/lib/newQueryBuilder/queryBuilderMappers/mapQueryDataFromApi.ts
index f30bfc13b7..733513b33b 100644
--- a/frontend/src/lib/newQueryBuilder/queryBuilderMappers/mapQueryDataFromApi.ts
+++ b/frontend/src/lib/newQueryBuilder/queryBuilderMappers/mapQueryDataFromApi.ts
@@ -33,5 +33,6 @@ export const mapQueryDataFromApi = (
clickhouse_sql: clickhouseSql,
queryType: compositeQuery.queryType,
id: uuid(),
+ unit: compositeQuery.unit,
};
};
diff --git a/frontend/src/providers/QueryBuilder.tsx b/frontend/src/providers/QueryBuilder.tsx
index 4de8de7d4a..7c1f1d9792 100644
--- a/frontend/src/providers/QueryBuilder.tsx
+++ b/frontend/src/providers/QueryBuilder.tsx
@@ -71,6 +71,7 @@ export const QueryBuilderContext = createContext<QueryBuilderContextType>({
updateAllQueriesOperators: () => initialQueriesMap.metrics,
updateQueriesData: () => initialQueriesMap.metrics,
initQueryBuilderData: () => {},
+ handleOnUnitsChange: () => {},
});
export function QueryBuilderProvider({
@@ -176,6 +177,7 @@ export function QueryBuilderProvider({
queryData: setupedQueryData,
},
id: query.id,
+ unit: query.unit,
};
const nextQuery: Query = {
@@ -474,6 +476,7 @@ export function QueryBuilderProvider({
promql,
clickhouse_sql: clickhouseSql,
id: uuid(),
+ unit: query.unit || initialQueryState.unit,
};
urlQuery.set(
@@ -513,6 +516,7 @@ export function QueryBuilderProvider({
promql: currentQuery.promql,
id: currentQuery.id,
queryType,
+ unit: currentQuery.unit,
},
maxTime,
minTime,
@@ -550,6 +554,16 @@ export function QueryBuilderProvider({
stagedQuery,
]);
+ const handleOnUnitsChange = useCallback(
+ (unit: string) => {
+ setCurrentQuery((prevState) => ({
+ ...prevState,
+ unit,
+ }));
+ },
+ [setCurrentQuery],
+ );
+
const query: Query = useMemo(
() => ({
...currentQuery,
@@ -585,6 +599,7 @@ export function QueryBuilderProvider({
updateAllQueriesOperators,
updateQueriesData,
initQueryBuilderData,
+ handleOnUnitsChange,
}),
[
query,
@@ -607,6 +622,7 @@ export function QueryBuilderProvider({
updateAllQueriesOperators,
updateQueriesData,
initQueryBuilderData,
+ handleOnUnitsChange,
],
);
diff --git a/frontend/src/store/actions/dashboard/getQueryResults.ts b/frontend/src/store/actions/dashboard/getQueryResults.ts
index 1487b3f7c8..a132fc8e78 100644
--- a/frontend/src/store/actions/dashboard/getQueryResults.ts
+++ b/frontend/src/store/actions/dashboard/getQueryResults.ts
@@ -34,6 +34,7 @@ export async function GetMetricQueryRange({
compositeQuery: {
queryType: query.queryType,
panelType: graphType,
+ unit: query?.unit,
},
};
diff --git a/frontend/src/types/api/alerts/compositeQuery.ts b/frontend/src/types/api/alerts/compositeQuery.ts
index 1f25718367..f2856fbb3d 100644
--- a/frontend/src/types/api/alerts/compositeQuery.ts
+++ b/frontend/src/types/api/alerts/compositeQuery.ts
@@ -3,6 +3,7 @@ import {
BuilderClickHouseResource,
BuilderPromQLResource,
BuilderQueryDataResourse,
+ Query,
} from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
@@ -12,4 +13,5 @@ export interface ICompositeMetricQuery {
chQueries: BuilderClickHouseResource;
queryType: EQueryType;
panelType: PANEL_TYPES;
+ unit: Query['unit'];
}
diff --git a/frontend/src/types/api/alerts/def.ts b/frontend/src/types/api/alerts/def.ts
index 8d5440e7d9..704a05765e 100644
--- a/frontend/src/types/api/alerts/def.ts
+++ b/frontend/src/types/api/alerts/def.ts
@@ -28,6 +28,7 @@ export interface RuleCondition {
op?: string | undefined;
target?: number | undefined;
matchType?: string | undefined;
+ targetUnit?: string | undefined;
}
export interface Labels {
diff --git a/frontend/src/types/api/queryBuilder/queryBuilderData.ts b/frontend/src/types/api/queryBuilder/queryBuilderData.ts
index b16aac3b3c..926785e072 100644
--- a/frontend/src/types/api/queryBuilder/queryBuilderData.ts
+++ b/frontend/src/types/api/queryBuilder/queryBuilderData.ts
@@ -1,3 +1,4 @@
+import { Format } from 'container/NewWidget/RightContainer/types';
import { EQueryType } from 'types/common/dashboard';
import {
DataSource,
@@ -82,6 +83,7 @@ export interface Query {
builder: QueryBuilderData;
clickhouse_sql: IClickHouseQuery[];
id: string;
+ unit?: Format['id'];
}
export type QueryState = Omit<Query, 'queryType'>;
diff --git a/frontend/src/types/common/queryBuilder.ts b/frontend/src/types/common/queryBuilder.ts
index 5e7cf57b02..3d74f30fdc 100644
--- a/frontend/src/types/common/queryBuilder.ts
+++ b/frontend/src/types/common/queryBuilder.ts
@@ -1,4 +1,5 @@
import { PANEL_TYPES } from 'constants/queryBuilder';
+import { Format } from 'container/NewWidget/RightContainer/types';
import {
IBuilderFormula,
IBuilderQuery,
@@ -187,6 +188,7 @@ export type QueryBuilderContextType = {
) => void;
handleRunQuery: () => void;
resetStagedQuery: () => void;
+ handleOnUnitsChange: (units: Format['id']) => void;
updateAllQueriesOperators: (
queryData: Query,
panelType: PANEL_TYPES,