diff --git a/nezha-fronted/src/components/page/config/about.vue b/nezha-fronted/src/components/page/config/about.vue index 2c7b91250..e9e3dfeec 100644 --- a/nezha-fronted/src/components/page/config/about.vue +++ b/nezha-fronted/src/components/page/config/about.vue @@ -44,7 +44,7 @@ export default { return { noData: false, timeLineData: [], - language: '', + // language: '', version: { nezha: { name: '', version: '' }, components: [{ name: '', version: '' }] @@ -274,18 +274,18 @@ export default { methods: { getVersion () { this.$get('/about').then(response => { - this.language = localStorage.getItem('nz-language') || 'en' + // this.language = localStorage.getItem('nz-language') || 'en' this.version = response.data }) } }, mounted () { this.getVersion() + }, + computed: { + language () { + return this.$store.getters.getLanguage + } } - // computed: { - // language () { - // return this.$store.getters.getLanguage - // } - // } } diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue index 43aed7532..31b859ea1 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue @@ -200,7 +200,8 @@
-
+ +

PromQL: Prometheus Query Language

@@ -1229,10 +1230,1042 @@ instance_cpu_time_ns{app="fox", proc="widget", rev="4d3a513", env="prod", job="c
-
+ + +
+
+ +

PromQL: Prometheus Query Language

+
+ +
+
    + +
  • +
    查询 Prometheus
    +
      +
    • 示例
    • +
    • 表达式语言数据类型
    • +
    • +
      字面量
      +
        +
      • 字符串字面量
      • +
      • 浮点字面量
      • +
      +
    • +
    • +
      时间序列选择器
      +
        +
      • 即时向量选择器
      • +
      • 范围向量选择器
      • +
      • 时间长度
      • +
      • offset 修饰符
      • +
      • @ 修饰符
      • +
      +
    • +
    • 子查询
    • +
    • 运算符
    • +
    • 函数
    • +
    • 注释
    • +
    • +
      陷阱
      +
        +
      • 过时
      • +
      • 避免缓慢的查询和过载
      • +
      +
    • +
    +
  • + +
  • +
    运算符
    +
      +
    • +
      二进制运算符
      +
        +
      • 二进制算术运算符
      • +
      • 三角二进制运算符
      • +
      • 比较二进制运算符
      • +
      • 逻辑 / 集合二进制运算符
      • +
      +
    • +
    • +
      向量匹配
      +
        +
      • 向量匹配关键词
      • +
      • 分组修饰符
      • +
      • 一对一向量匹配
      • +
      • 多对一 / 一对多向量匹配
      • +
      +
    • +
    • 聚合运算符
    • +
    • 二进制运算符优先级
    • +
    +
  • + +
  • +
    函数
    +
      +
    • abs()
    • +
    • absent()
    • +
    • absent_over_time()
    • +
    • ceil()
    • +
    • changes()
    • +
    • clamp()
    • +
    • clamp_max()
    • +
    • clamp_min()
    • +
    • day_of_month()
    • +
    • day_of_week()
    • +
    • day_of_year()
    • +
    • days_in_month()
    • +
    • delta()
    • +
    • deriv()
    • +
    • exp()
    • +
    • floor()
    • +
    • histogram_quantile()
    • +
    • holt_winters()
    • +
    • hour()
    • +
    • idelta()
    • +
    • increase()
    • +
    • irate()
    • +
    • label_join()
    • +
    • label_replace()
    • +
    • ln()
    • +
    • log2()
    • +
    • log10()
    • +
    • minute()
    • +
    • month()
    • +
    • predict_linear()
    • +
    • rate()
    • +
    • resets()
    • +
    • round()
    • +
    • scalar()
    • +
    • sgn()
    • +
    • sort()
    • +
    • sort_desc()
    • +
    • sqrt()
    • +
    • time()
    • +
    • timestamp()
    • +
    • vector()
    • +
    • year()
    • +
    • <aggregation>_over_time()
    • +
    • 三角函数
    • +
    +
  • + +
  • +
    查询示例
    +
      +
    • 简单的时间序列选择
    • +
    • Subquery 子查询
    • +
    • 使用函数、运算符等
    • +
    +
  • +
+
+ + +
+

查询 Prometheus

+

Prometheus 提供一种名为 PromQL(Prometheus Query Language)的函数式查询语言,允许用户实时选择和聚合时间序列数据。表达式的结果可以显示为图形,也可以作为表格数据在 Prometheus 表达式浏览器中查看,或通过 HTTP API 由外部系统使用。

+
+ +
+

示例

+

本文件可作为参考。首先了解一些示例会对学习有帮助。

+
+ +
+

表达式语言数据类型

+ +
+ +

字面量

+
+

字符串字面量

+ +
+ +
+

浮点字面量

+ +
+ +

时间序列选择器

+
+

即时向量选择器

+ +
+ +
+

范围向量选择器

+ +
+ +
+

时间长度

+ +
+ +
+

offset 修饰符

+ +
+ +
+

@ 修饰符

+ +
+ +
+

子查询

+ +
+ +
+

运算符

+ +
+ +
+

函数

+ +
+ +
+

注释

+ +
+ +

陷阱

+
+

过时

+ +
+ +
+

避免缓慢的查询和过载

+ +
+ +

运算符

+
+

二进制运算符

+

Prometheus 的查询语言支持基本的逻辑和算术运算符。对于两个即时向量之间的运算,可以修改匹配行为

+
+ +
+

二进制算术运算符

+ +
+ +
+

三角二进制运算符

+ +
+ +
+

比较二进制运算符

+ +
+ +
+

逻辑 / 集合二进制运算符

+ +
+ +

向量匹配

+
+ +
+ +
+

向量匹配关键词

+ +
+ +
+

分组修饰符

+ +
+ +
+

一对一向量匹配

+ +
+ +
+

多对一 / 一对多向量匹配

+ +
+ +
+

聚合运算符

+ +
+ +
+

二进制运算符优先级

+ +
+ +

函数

+
+ +
+ +
+

abs()

+ +
+ +
+

absent()

+ +
+ +
+

absent_over_time()

+ +
+ +
+

ceil()

+ +
+ +
+

changes()

+ +
+ +
+

clamp()

+ +
+ +
+

clamp_max()

+ +
+ +
+

clamp_min()

+ +
+ +
+

day_of_month()

+ +
+ +
+

day_of_week()

+ +
+ +
+

day_of_year()

+ +
+ +
+

days_in_month()

+ +
+ +
+

delta()

+ +
+ +
+

deriv()

+ +
+ +
+

exp()

+ +
+ +
+

floor()

+ +
+ +
+

histogram_quantile()

+ +
+ +
+

holt_winters()

+ +
+ +
+

hour()

+ +
+ +
+

idelta()

+ +
+ +
+

increase()

+ +
+ +
+

irate()

+ +
+ +
+

label_join()

+ +
+ +
+

label_replace()

+ +
+ +
+

ln()

+ +
+ +
+

log2()

+ +
+ +
+

log10()

+ +
+ +
+

minute()

+ +
+ +
+

month()

+ +
+ +
+

predict_linear()

+ +
+ +
+

rate()

+ +
+ +
+

resets()

+ +
+ +
+

round()

+ +
+ +
+

scalar()

+ +
+ +
+

sgn()

+ +
+ +
+

sort()

+ +
+ +
+

sort_desc()

+ +
+ +
+

sqrt()

+ +
+ +
+

time()

+ +
+ +
+

timestamp()

+ +
+ +
+

vector()

+ +
+ +
+

year()

+ +
+ +
+

<aggregation>_over_time()

+ +
+ +
+

三角函数

+ +
+ +

查询示例

+
+

简单的时间序列选择

+ +
+ +
+

Subquery子查询

+ +
+ +
+

使用函数、运算符等

+ +
+
+
-
+ +

LogQL: Log Query Language

@@ -1779,6 +2812,598 @@ level=info ts=2020-10-23T20:32:18.068866235Z caller=metrics.go:81 org_id=29 trac

This example calculates the p99 of the nginx-ingress latency by path.

sum by (org_id) (
   sum_over_time(
+  {cluster="ops-tools1",container="loki-dev"}
+      |= "metrics.go"
+      | logfmt
+      | unwrap bytes_processed [1m])
+  )
+

This calculates the amount of bytes processed per organization ID.

+
+
+ +
+

Built-in aggregation operators

+ +
+ +
+

Vector aggregation examples

+ +
+
+
+ +
+
+ +

LogQL:日志查询语言

+
+ +
+
    +
  • +
    Log queries
    +
      +
    • Log stream selector
    • +
    • +
      Log pipeline
      +
        +
      • Line filter expression
      • +
      • Label filter expression
      • +
      • Parser expression
      • +
      • JSON
      • +
      • logfmt
      • +
      • Pattern
      • +
      • Regular expression
      • +
      • unpack
      • +
      • Line format expression
      • +
      • Labels format expression
      • +
      +
    • +
    • +
      Log queries examples
      +
        +
      • Multiple filtering
      • +
      • Multiple parsers
      • +
      • Formatting
      • +
      +
    • +
    +
  • +
  • +
    Metric queries
    +
      +
    • +
      Range Vector aggregation
      +
        +
      • Log range aggregations
      • +
      • Unwrapped range aggregations
      • +
      • Unwrapped examples
      • +
      +
    • +
    • +
      Built-in aggregation operators
      +
      • Vector aggregation examples
      +
    • +
    +
  • +
+
+
+

LogQL is Grafana Loki’s PromQL-inspired query language. Queries act as if they are a distributed grep to aggregate log sources. LogQL uses labels and operators for filtering.

+

There are two types of LogQL queries:

+
    +
  • Log queries return the contents of log lines.
  • +
  • Metric queries extend log queries to calculate values based on query results.
  • +
+
+ + + +
+

Log queries

+

All LogQL queries contain a log stream selector.

+
+

Optionally, the log stream selector can be followed by a log pipeline. A log pipeline is a set of stage expressions that are chained together and applied to the selected log streams. Each expression can filter out, parse, or mutate log lines and their respective labels.

+

The following example shows a full log query in action:

+

{container="query-frontend",namespace="loki-dev"} |= "metrics.go" | logfmt | duration > 10s and throughput_mb < 500

+

The query is composed of:

+
    +
  • a log stream selector {container="query-frontend",namespace="loki-dev"} which targets the query-frontend container in the loki-dev namespace.
  • +
  • a log pipeline |= "metrics.go" | logfmt | duration > 10s and throughput_mb < 500 which will filter out log that contains the word metrics.go, then parses each log line to extract more labels and filter with them.
  • +
+
To avoid escaping special characters you can use the `(backtick) instead of " when quoting strings. For example `\w+` is the same as "\\w+". This is specially useful when writing a regular expression which contains multiple 
backslashes that require escaping.
+
+ +
+

Log stream selector

+ +
+ +
+

Log pipeline

+ +
+ +
+

Line filter expression

+ +
+ +
+

Label filter expression

+ +
+ +
+

Parser expression

+ +
+ +
+

JSON

+ +
+ +
+

logfmt

+ +
+ +
+

Pattern

+ +
+ +
+

Regular expression

+ +
+ +
+

unpack

+ +
+ +
+

Line format expression

+ +
+ +
+

Labels format expression

+ +
+ +

Log queries examples

+ +
+

Multiple filtering

+ +
+ +
+

Multiple parsers

+ +
+ +
+

Formatting

+ +
+ + +
+

Metric queries

+ +
+ +
+

Range Vector aggregation

+ +
+ +
+

Log range aggregations

+ +
+ +
+

Unwrapped range aggregations

+ +
+ +
+

Unwrapped examples

+