The engine executes LogQL query and gets time series data with labels (Vector). The engine iterates through each series, extracting values to compare against configured threshold expressions.
Recovery logic
See Alert recovery for the recovery options. A recovery query is a separate LogQL statement.
Data exists mode
This mode is suitable for users who prefer writing filter conditions directly in LogQL, or scenarios that only care about “whether anomalous data exists”. Recommended for log anomaly detection alerts.
Configuration
Query Statement (LogQL): Write LogQL containing comparison operators, returning only data satisfying conditions
Example: Directly filter services with error rate exceeding 5%:
Evaluation Rules: As long as LogQL query returns data, triggers alert
Data exists mode computes on the Loki server, which reduces data transfer; however, it cannot distinguish alert levels and can only trigger a single level.
This mode is used to monitor whether log reporting pipeline is interrupted, or whether logs that should be continuously generated have stopped.
Configuration
Query Statement (LogQL): Write a query that is expected to always have data
Example: Count log reporting rate from all hosts:
rate({job="node-logs"} [1m])
Evaluation Rules: If a Series (uniquely identified by labels, like instance="host-1") existed in previous cycles but cannot be found in current and N consecutive cycles, triggers “No Data” alert
Monitor whether Promtail/Fluentd and other collection Agents have stopped working
Monitor whether critical business logs (like order creation logs) are abnormally interrupted
Using a raw log query as the primary query
To alert whenever matching log rows exist, select Raw log and use Data exists mode. Suppose the query returns job, service, __time__, and __log__:
Label fields: Select stable dimensions such as job and service to identify the alert object.
Value fields: Leave this empty in Data exists mode. If you use Threshold evaluation, select a field that can be converted to a number.
Additional information: __time__, __log__, and any other unselected non-value fields are automatically carried with the alert.
Do not use frequently changing fields such as __time__, __log__, or a trace ID as labels. Otherwise, each log row may create a different alert object.
See Query result field mapping for default behavior, threshold references, and multi-query matching requirements.
Getting raw logs through a related query
You can get original logs through related queries during alerts. Don’t fetch too many; one log sample in the alert message is usually enough.Related query results can be rendered in “Notes Description”, example:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Flashduty Docs","description":"Flashduty 官方文档,涵盖 On-call 告警响应、Monitors 监控、RUM 与 AI SRE 的配置指南、集成方式和 API 参考。","colors":{"primary":"#8B5CF6","light":"#8B5CF6","dark":"#8B5CF6"},"logo":{"light":"https://mintcdn.com/flashduty-com/FpfuLufyi4FJe6mQ/logo/saas-logo.svg?fit=max\u0026auto=format\u0026n=FpfuLufyi4FJe6mQ\u0026q=85\u0026s=1656361bf7575f7275615ac9191db061","dark":"https://mintcdn.com/flashduty-com/FpfuLufyi4FJe6mQ/logo/saas-logo-white.svg?fit=max\u0026auto=format\u0026n=FpfuLufyi4FJe6mQ\u0026q=85\u0026s=744bbbd3bb703e9db8183af2ee98f185","href":"https://flashduty.com/"},"favicon":"https://mintcdn.com/flashduty-com/FpfuLufyi4FJe6mQ/logo/saas-favicon.png?fit=max\u0026auto=format\u0026n=FpfuLufyi4FJe6mQ\u0026q=85\u0026s=377e85b5ba71d5351ee7f84b5d70b1e1","navbar":{"links":[{"icon":"code","href":"/zh/openapi/introduction","label":"API Reference"}],"primary":{"type":"button","label":"Console","href":"https://console.flashcat.cloud"}},"seo":{"metatags":{"canonical":"https://docs.flashduty.com"},"organization":{"id":"https://flashduty.com/#organization","name":"Flashduty","legalName":"北京快猫星云科技有限公司","url":"https://flashduty.com/","logo":"https://docs.flashduty.com/logo/saas-logo.svg","sameAs":["https://github.com/flashcatcloud"]},"indexing":"all"},"styling":{"latex":true},"navigation":{"languages":[{"language":"zh","footer":{"socials":{"github":"https://github.com/flashcatcloud"},"links":[{"header":"Flashduty","items":[{"label":"官网","href":"https://www.flashduty.com/zh"},{"label":"定价","href":"https://www.flashduty.com/zh/pricing"},{"label":"集成目录","href":"https://www.flashduty.com/zh/integrations"},{"label":"博客","href":"https://www.flashduty.com/zh/now/blog"}]},{"header":"支持","items":[{"label":"联系我们","href":"https://www.flashduty.com/zh/contact"},{"label":"安全与合规","href":"https://www.flashduty.com/zh/legal/security"},{"label":"服务 SLA","href":"/zh/compliance/service-sla"}]},{"header":"法律","items":[{"label":"服务条款","href":"/zh/compliance/terms-of-service"},{"label":"用户协议","href":"/zh/compliance/user-agreement"},{"label":"隐私政策","href":"/zh/compliance/privacy-policy"},{"label":"退款政策","href":"/zh/compliance/refund-policy"}]}]},"navbar":{"links":[{"icon":"code","href":"/zh/openapi/introduction","label":"API 参考"}],"primary":{"type":"button","label":"控制台","href":"https://console.flashcat.cloud"}},"href":"zh/home"},{"language":"en","footer":{"socials":{"github":"https://github.com/flashcatcloud"},"links":[{"header":"Flashduty","items":[{"label":"Website","href":"https://www.flashduty.com/en"},{"label":"Pricing","href":"https://www.flashduty.com/en/pricing"},{"label":"Integrations","href":"https://www.flashduty.com/en/integrations"},{"label":"Blog","href":"https://www.flashduty.com/en/now/blog"}]},{"header":"Support","items":[{"label":"Contact us","href":"https://www.flashduty.com/en/contact"},{"label":"Security","href":"https://www.flashduty.com/en/legal/security"},{"label":"Service SLA","href":"/en/compliance/service-sla"}]},{"header":"Legal","items":[{"label":"Terms of Service","href":"/en/compliance/terms-of-service"},{"label":"User Agreement","href":"/en/compliance/user-agreement"},{"label":"Privacy Policy","href":"/en/compliance/privacy-policy"},{"label":"Refund Policy","href":"/en/compliance/refund-policy"}]}]},"navbar":{"links":[{"icon":"code","href":"/en/openapi/introduction","label":"API Reference"}],"primary":{"type":"button","label":"Console","href":"https://console.flashcat.cloud"}},"href":"en/home"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"flashduty-com","hasAudioNarration":false,"actualSubdomain":"flashduty-com","customDomains":["docs.flashduty.com"],"gitSource":{"type":"github","owner":"flashcatcloud","repo":"flashduty-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6affc7d52bab8c36268d629d","clientVersion":"0.0.4227","searchFilterCounts":[{"language":"en","tag":"On-call","count":621},{"language":"zh","tag":"On-call","count":621},{"language":"en","tag":"API Reference","count":396},{"language":"zh","tag":"API 参考","count":396},{"language":"en","tag":"Integrations","count":378},{"language":"zh","tag":"集成中心","count":378},{"language":"en","tag":"Alert Integration","count":297},{"language":"zh","tag":"告警集成","count":297},{"language":"en","tag":"RUM","count":125},{"language":"zh","tag":"RUM","count":125},{"language":"en","tag":"AI SRE","count":70},{"language":"en","tag":"Monitors","count":70},{"language":"zh","tag":"AI SRE","count":70},{"language":"zh","tag":"Monitors","count":70},{"language":"zh","tag":"故障管理","count":65},{"language":"en","tag":"Incidents","count":55},{"language":"en","tag":"Change Integration","count":40},{"language":"en","tag":"SDK Integration","count":40},{"language":"zh","tag":"变更集成","count":40},{"language":"zh","tag":"SDK 接入","count":40}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"en/monitors/alert-rules/loki","slug":"/en/monitors/alert-rules/loki","pageMetadata":{"title":"Loki","description":"Configure alert rules for Loki data sources with LogQL query syntax support","href":"/en/monitors/alert-rules/loki"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Configure alert rules for Loki data sources with LogQL query syntax support\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,img:`img`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Monitors supports Loki’s LogQL query syntax, enabling aggregate analysis on log data and triggering alerts.`}),`\n`,_jsx(Heading,{level:`2`,id:`core-concepts`,children:`Core concepts`}),`\n`,_jsx(_components.p,{children:`Loki’s query language LogQL is divided into two types:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Log Queries`})}),_jsx(_components.td,{children:`Returns log line content (Stream)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Metric Queries`})}),_jsxs(_components.td,{children:[`Counts or aggregates logs, like `,_jsx(_components.code,{children:`count_over_time`}),` returns values (Vector)`]})]})]})]}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`When writing LogQL, the query input autocompletes label names and label values from the data source, helping you locate log streams quickly.`})}),`\n`,_jsx(Heading,{level:`2`,id:`threshold-evaluation-mode`,children:`Threshold evaluation mode`}),`\n`,_jsx(_components.p,{children:`This mode is suitable for scenarios requiring multi-level threshold evaluation on log aggregate values (for example, Info/Warning/Critical).`}),`\n`,_jsx(Heading,{level:`3`,id:`configuration`,children:`Configuration`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Query Statement (LogQL)`}),`: Write LogQL that returns numeric vectors (select “Do Stats” query mode)`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Example`}),`: Count log lines containing `,_jsx(_components.code,{children:`error`}),` keyword in `,_jsx(_components.code,{children:`mysql`}),` job in the last 5 minutes:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`count_over_time({job=\"mysql\"} |= \"error\" [5m])`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Threshold Conditions`}),`:`,`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Critical`}),`: `,_jsx(_components.code,{children:`$A > 50`}),` (Error logs exceed 50 in 5 minutes)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Warning`}),`: `,_jsx(_components.code,{children:`$A > 10`}),` (Error logs exceed 10 in 5 minutes)`]}),`\n`]}),`\n`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`how-it-works`,children:`How it works`}),`\n`,_jsx(_components.p,{children:`The engine executes LogQL query and gets time series data with labels (Vector). The engine iterates through each series, extracting values to compare against configured threshold expressions.`}),`\n`,_jsx(Heading,{level:`3`,id:`recovery-logic`,children:`Recovery logic`}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/en/monitors/quickstart/quickstart#alert-recovery`,children:`Alert recovery`}),` for the recovery options. A recovery query is a separate LogQL statement.`]}),`\n`,_jsx(Heading,{level:`2`,id:`data-exists-mode`,children:`Data exists mode`}),`\n`,_jsx(_components.p,{children:`This mode is suitable for users who prefer writing filter conditions directly in LogQL, or scenarios that only care about “whether anomalous data exists”. Recommended for log anomaly detection alerts.`}),`\n`,_jsx(Heading,{level:`3`,id:`configuration-2`,children:`Configuration`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Query Statement (LogQL)`}),`: Write LogQL containing comparison operators, returning only data satisfying conditions`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Example`}),`: Directly filter services with error rate exceeding 5%:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`count_over_time({job=\"ingress\"} |= \"error-code-500\" [5m]) / count_over_time({job=\"ingress\"} [5m]) * 100 > 5`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Evaluation Rules`}),`: As long as LogQL query returns data, triggers alert`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`Data exists mode computes on the Loki server, which reduces data transfer; however, it cannot distinguish alert levels and can only trigger a single level.`}),`\n`,_jsx(Heading,{level:`3`,id:`recovery-logic-2`,children:`Recovery logic`}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/en/monitors/quickstart/quickstart#alert-recovery`,children:`Alert recovery`}),` for the recovery options.`]}),`\n`,_jsx(Heading,{level:`2`,id:`no-data-mode`,children:`No data mode`}),`\n`,_jsx(_components.p,{children:`This mode is used to monitor whether log reporting pipeline is interrupted, or whether logs that should be continuously generated have stopped.`}),`\n`,_jsx(Heading,{level:`3`,id:`configuration-3`,children:`Configuration`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Query Statement (LogQL)`}),`: Write a query that is expected to always have data`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Example`}),`: Count log reporting rate from all hosts:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`rate({job=\"node-logs\"} [1m])`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Evaluation Rules`}),`: If a Series (uniquely identified by labels, like `,_jsx(_components.code,{children:`instance=\"host-1\"`}),`) existed in previous cycles but cannot be found in current and N consecutive cycles, triggers “No Data” alert`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`recovery-logic-3`,children:`Recovery logic`}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/en/monitors/quickstart/quickstart#alert-recovery`,children:`Alert recovery`}),` for the recovery options.`]}),`\n`,_jsx(Heading,{level:`3`,id:`typical-applications`,children:`Typical applications`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Monitor whether Promtail/Fluentd and other collection Agents have stopped working`}),`\n`,_jsx(_components.li,{children:`Monitor whether critical business logs (like order creation logs) are abnormally interrupted`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`using-a-raw-log-query-as-the-primary-query`,children:`Using a raw log query as the primary query`}),`\n`,_jsxs(_components.p,{children:[`To alert whenever matching log rows exist, select `,_jsx(_components.strong,{children:`Raw log`}),` and use `,_jsx(_components.strong,{children:`Data exists`}),` mode. Suppose the query returns `,_jsx(_components.code,{children:`job`}),`, `,_jsx(_components.code,{children:`service`}),`, `,_jsx(_components.code,{children:`__time__`}),`, and `,_jsx(_components.code,{children:`__log__`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Label fields`}),`: Select stable dimensions such as `,_jsx(_components.code,{children:`job`}),` and `,_jsx(_components.code,{children:`service`}),` to identify the alert object.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Value fields`}),`: Leave this empty in Data exists mode. If you use Threshold evaluation, select a field that can be converted to a number.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Additional information`}),`: `,_jsx(_components.code,{children:`__time__`}),`, `,_jsx(_components.code,{children:`__log__`}),`, and any other unselected non-value fields are automatically carried with the alert.`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Do not use frequently changing fields such as `,_jsx(_components.code,{children:`__time__`}),`, `,_jsx(_components.code,{children:`__log__`}),`, or a trace ID as labels. Otherwise, each log row may create a different alert object.`]})}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/en/monitors/alert-rules/query-result-fields`,children:`Query result field mapping`}),` for default behavior, threshold references, and multi-query matching requirements.`]}),`\n`,_jsx(Heading,{level:`2`,id:`getting-raw-logs-through-a-related-query`,children:`Getting raw logs through a related query`}),`\n`,_jsx(_components.p,{children:`You can get original logs through related queries during alerts. Don’t fetch too many; one log sample in the alert message is usually enough.`}),`\n`,_jsx(_components.p,{children:_jsx(_components.img,{src:`https://docs-cdn.flashcat.cloud/imges/mon/ca5ea15fcfca066f260e09d0f8d91cf2.png`,alt:`Loki: Getting raw logs through a related query screenshot`})}),`\n`,_jsx(_components.p,{children:`Related query results can be rendered in “Notes Description”, example:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{{- if eq $status \"firing\" }}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`error log count: {{ $value | printf \"%.3f\" }}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{{- range $x := $relates.R1}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Loki log time: {{(nanoTime $x.Fields.__time__ 8).Format \"2006-01-02T15:04:05Z07:00\"}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Loki Log line: {{$x.Fields.__log__}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{{- end}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{{- end}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Loki","description":"Configure alert rules for Loki data sources with LogQL query syntax support","href":"/en/monitors/alert-rules/loki"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Core concepts","slug":"core-concepts","depth":2,"children":[]},{"title":"Threshold evaluation mode","slug":"threshold-evaluation-mode","depth":2,"children":[{"title":"Configuration","slug":"configuration","depth":3,"children":[]},{"title":"How it works","slug":"how-it-works","depth":3,"children":[]},{"title":"Recovery logic","slug":"recovery-logic","depth":3,"children":[]}]},{"title":"Data exists mode","slug":"data-exists-mode","depth":2,"children":[{"title":"Configuration","slug":"configuration-2","depth":3,"children":[]},{"title":"Recovery logic","slug":"recovery-logic-2","depth":3,"children":[]}]},{"title":"No data mode","slug":"no-data-mode","depth":2,"children":[{"title":"Configuration","slug":"configuration-3","depth":3,"children":[]},{"title":"Recovery logic","slug":"recovery-logic-3","depth":3,"children":[]},{"title":"Typical applications","slug":"typical-applications","depth":3,"children":[]}]},{"title":"Using a raw log query as the primary query","slug":"using-a-raw-log-query-as-the-primary-query","depth":2,"children":[]},{"title":"Getting raw logs through a related query","slug":"getting-raw-logs-through-a-related-query","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"flashduty-com","siteName":"Flashduty Docs","title":"Loki - Flashduty Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"zh":{"href":"/zh/monitors/alert-rules/loki","matchLevel":1},"en":{"href":"/en/monitors/alert-rules/loki","matchLevel":0}}},"lastModified":"2026-11-12T08:48:49.389Z","originalFileLocation":"en/monitors/alert-rules/loki.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Configure alert rules for Loki data sources with LogQL query syntax support\">\u003cmeta data-mint-head name=\"application-name\" content=\"Flashduty Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Loki - Flashduty Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Configure alert rules for Loki data sources with LogQL query syntax support\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Flashduty Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.flashduty.com/en/monitors/alert-rules/loki\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://flashduty-com.mintlify.site/_mintlify/api/og/v2?division=Alert+Rules\u0026amp;title=Loki\u0026amp;description=Configure+alert+rules+for+Loki+data+sources+with+LogQL+query+syntax+support\u0026amp;theme=e69468df7fc0f2b1601c6217\u0026amp;signature=52ce7f1e63a04661f11d37472c973a44adab7aac6d28131005a0b67c9430e933\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Loki - Flashduty Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Configure alert rules for Loki data sources with LogQL query syntax support\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://flashduty-com.mintlify.site/_mintlify/api/og/v2?division=Alert+Rules\u0026amp;title=Loki\u0026amp;description=Configure+alert+rules+for+Loki+data+sources+with+LogQL+query+syntax+support\u0026amp;theme=e69468df7fc0f2b1601c6217\u0026amp;signature=52ce7f1e63a04661f11d37472c973a44adab7aac6d28131005a0b67c9430e933\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/flashduty-com/ZomM9gFDgYEBUD0S/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Flashduty Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#8B5CF6\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.flashduty.com/en/monitors/alert-rules/loki\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/en/monitors/alert-rules/loki.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.flashduty.com/en/monitors/alert-rules/loki\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh\" href=\"https://docs.flashduty.com/zh/monitors/alert-rules/loki\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.flashduty.com/zh/monitors/alert-rules/loki\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://flashduty.com/#organization\",\"name\":\"Flashduty\",\"legalName\":\"北京快猫星云科技有限公司\",\"url\":\"https://flashduty.com/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://docs.flashduty.com/logo/saas-logo.svg\"},\"sameAs\":[\"https://github.com/flashcatcloud\"]},{\"@type\":\"WebSite\",\"@id\":\"https://docs.flashduty.com#website\",\"name\":\"Flashduty Docs\",\"url\":\"https://docs.flashduty.com\",\"publisher\":{\"@id\":\"https://flashduty.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki#webpage\",\"url\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki\",\"name\":\"Loki\",\"description\":\"Configure alert rules for Loki data sources with LogQL query syntax support\",\"dateModified\":\"2026-11-12T08:48:49.389Z\",\"isPartOf\":{\"@id\":\"https://docs.flashduty.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Alert Rules\",\"item\":\"https://docs.flashduty.com/en/monitors/alert-rules/prometheus\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Loki\",\"item\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki#article\",\"headline\":\"Loki\",\"name\":\"Loki\",\"description\":\"Configure alert rules for Loki data sources with LogQL query syntax support\",\"url\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki\",\"mainEntityOfPage\":{\"@id\":\"https://docs.flashduty.com/en/monitors/alert-rules/loki#webpage\"},\"dateModified\":\"2026-11-12T08:48:49.389Z\",\"publisher\":{\"@id\":\"https://flashduty.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.flashduty.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Flashduty Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Flashduty\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/en/monitors/alert-rules/loki.md","siteName":"Flashduty Docs","nav":{"global":null,"languages":[{"language":"zh","footer":{"socials":{"github":"https://github.com/flashcatcloud"},"links":[{"header":"Flashduty","items":[{"label":"官网","href":"https://www.flashduty.com/zh"},{"label":"定价","href":"https://www.flashduty.com/zh/pricing"},{"label":"集成目录","href":"https://www.flashduty.com/zh/integrations"},{"label":"博客","href":"https://www.flashduty.com/zh/now/blog"}]},{"header":"支持","items":[{"label":"联系我们","href":"https://www.flashduty.com/zh/contact"},{"label":"安全与合规","href":"https://www.flashduty.com/zh/legal/security"},{"label":"服务 SLA","href":"/zh/compliance/service-sla"}]},{"header":"法律","items":[{"label":"服务条款","href":"/zh/compliance/terms-of-service"},{"label":"用户协议","href":"/zh/compliance/user-agreement"},{"label":"隐私政策","href":"/zh/compliance/privacy-policy"},{"label":"退款政策","href":"/zh/compliance/refund-policy"}]}]},"navbar":{"links":[{"icon":"code","href":"/zh/openapi/introduction","label":"API 参考"}],"primary":{"type":"button","label":"控制台","href":"https://console.flashcat.cloud"}},"pages":[{"title":"zh","href":"/zh/monitors/alert-rules/loki"}]},{"language":"en","footer":{"socials":{"github":"https://github.com/flashcatcloud"},"links":[{"header":"Flashduty","items":[{"label":"Website","href":"https://www.flashduty.com/en"},{"label":"Pricing","href":"https://www.flashduty.com/en/pricing"},{"label":"Integrations","href":"https://www.flashduty.com/en/integrations"},{"label":"Blog","href":"https://www.flashduty.com/en/now/blog"}]},{"header":"Support","items":[{"label":"Contact us","href":"https://www.flashduty.com/en/contact"},{"label":"Security","href":"https://www.flashduty.com/en/legal/security"},{"label":"Service SLA","href":"/en/compliance/service-sla"}]},{"header":"Legal","items":[{"label":"Terms of Service","href":"/en/compliance/terms-of-service"},{"label":"User Agreement","href":"/en/compliance/user-agreement"},{"label":"Privacy Policy","href":"/en/compliance/privacy-policy"},{"label":"Refund Policy","href":"/en/compliance/refund-policy"}]}]},"navbar":{"links":[{"icon":"code","href":"/en/openapi/introduction","label":"API Reference"}],"primary":{"type":"button","label":"Console","href":"https://console.flashcat.cloud"}},"tabs":[{"tab":"Home","icon":"house","pages":[{"title":"Home","href":"/en/home"}]},{"tab":"AI SRE","icon":"sparkles","pages":[{"title":"AI SRE","href":"/en/ai-sre/quickstart"}]},{"tab":"On-call","icon":"light-emergency-on","pages":[{"title":"On-call","href":"/en/on-call/quickstart/quickstart"}]},{"tab":"RUM","icon":"monitor-waveform","pages":[{"title":"RUM","href":"/en/rum/quickstart/quickstart"}]},{"tab":"Monitors","icon":"chart-area","groups":[{"group":"Quick Start","icon":"rocket","pages":[{"title":"Get started with Flashduty Monitors","sidebarTitle":"Get started","href":"/en/monitors/quickstart/quickstart"}]},{"group":"Data Sources","icon":"database","pages":[{"title":"Data source management","href":"/en/monitors/data-sources/data-sources"}]},{"group":"Query Workbench","icon":"magnifying-glass-chart","pages":[{"title":"Query workbench","href":"/en/monitors/explore/explore"}]},{"group":"Dashboards","icon":"chart-line","pages":[{"title":"Dashboards","href":"/en/monitors/dashboards/dashboards"}]},{"group":"Entity Tree","icon":"sitemap","pages":[{"title":"Entity Tree","href":"/en/monitors/entity-tree/entity-tree"}]},{"group":"Alert Engine","icon":"gears","pages":[{"title":"Alert engine management","href":"/en/monitors/engine/engine"},{"title":"Engine disconnection alert","href":"/en/monitors/engine/engine-lost-alert"},{"title":"Engine self-monitoring metrics","href":"/en/monitors/engine/self-monitoring"}]},{"group":"Alert Rules","icon":"list-check","pages":[{"title":"Prometheus","href":"/en/monitors/alert-rules/prometheus"},{"title":"ElasticSearch","description":"Configure alert rules for ElasticSearch data sources with SQL aggregate query support","href":"/en/monitors/alert-rules/elasticsearch"},{"title":"Loki","href":"/en/monitors/alert-rules/loki"},{"title":"ClickHouse","description":"Configure alert rules for ClickHouse data sources with standard SQL syntax support","href":"/en/monitors/alert-rules/clickhouse"},{"title":"MySQL","href":"/en/monitors/alert-rules/mysql"},{"title":"Oracle","href":"/en/monitors/alert-rules/oracle"},{"title":"PostgreSQL","href":"/en/monitors/alert-rules/postgres"},{"title":"SLS","href":"/en/monitors/alert-rules/sls"},{"title":"Tencent CLS","href":"/en/monitors/alert-rules/tencent-cls"},{"title":"VictoriaLogs","href":"/en/monitors/alert-rules/victorialogs"},{"title":"Query result field mapping","href":"/en/monitors/alert-rules/query-result-fields"},{"title":"Description template","href":"/en/monitors/alert-rules/description-template"},{"title":"Investigation entries","href":"/en/monitors/alert-rules/investigation-entries"}]},{"group":"Active Alerts","icon":"bell","pages":[{"title":"Active alerts","href":"/en/monitors/alert-rules/active-alerts"}]},{"group":"Folder Management","icon":"folder-open","pages":[{"title":"Folder management","href":"/en/monitors/folders/folders"}]},{"group":"FAQ","icon":"circle-question","pages":[{"title":"Flashduty Monitors FAQ","sidebarTitle":"FAQ","href":"/en/monitors/faq/faq"}]}]},{"tab":"API Reference","icon":"terminal","hidden":true,"pages":[{"title":"API Reference","href":"/en/openapi/introduction"}]}]}]},"basePath":"","title":"Loki - Flashduty Docs","deploymentId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","buildId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-BguUeq2N.js","lightbox-handle-r17bVUz3.js"]}