SkyWalking内置MQE语法
此文档出自SkyWalking官方git https://github.com/apache/skywalking
docs/en/api/metrics-query-expression.md
Metrics Query Expression(MQE) Syntax
MQE is a string that consists of one or more expressions. Each expression could be a combination of one or more operations.
The expression allows users to do simple query-stage calculation through V3 APIs.
Expression = <Operation> Expression1 <Operation> Expression2 <Operation> Expression3 ...
The following document lists the operations supported by MQE.
Metrics Expression
Metrics Expression will return a collection of time-series values.
Common Value Metrics
Expression:
<metric_name>
For example:
If we want to query the service_sla
metric, we can use the following expression:
service_sla
Result Type
The ExpressionResultType
of the expression is TIME_SERIES_VALUES
.
Labeled Value Metrics
For now, we only have a single anonymous label with multi label values in a labeled metric.
To be able to use it in expressions, define _
as the anonymous label name (key).
Expression:
<metric_name>{_='<label_value_1>,...'}
{_='<label_value_1>,...'}
is the selected label value of the metric. If is not specified, all label values of the metric will be selected.
For example:
If we want to query the service_percentile
metric with the label values 0,1,2,3,4
, we can use the following expression:
service_percentile{_='0,1,2,3,4'}
If we want to rename the label values to P50,P75,P90,P95,P99
, see Relabel Operation.
Result Type
The ExpressionResultType
of the expression is TIME_SERIES_VALUES
and with labels.
Binary Operation
The Binary Operation is an operation that takes two expressions and performs a calculation on their results.
The following table lists the binary operations supported by MQE.
Expression:
Expression1 <Binary-Operator> Expression2
Operator | Definition |
---|---|
+ | addition |
- | subtraction |
* | multiplication |
/ | division |
% | modulo |
For example:
If we want to transform the service_sla metric value to percent, we can use the following expression:
service_sla / 100
Result Type
For the result type of the expression, please refer to the following table.
Binary Operation Rules
The following table lists if the different result types of the input expressions could do this operation and the result type after the operation.
The expression could be on the left or right side of the operator.
Note: If the expressions on both sides of the operator are the TIME_SERIES_VALUES with labels
, they should have the same labels for calculation.
Expression | Expression | Yes/No | ExpressionResultType |
---|---|---|---|
SINGLE_VALUE | SINGLE_VALUE | Yes | SINGLE_VALUE |
SINGLE_VALUE | TIME_SERIES_VALUES | Yes | TIME_SERIES_VALUES |
SINGLE_VALUE | SORTED_LIST/RECORD_LIST | Yes | SORTED_LIST/RECORD_LIST |
TIME_SERIES_VALUES | TIME_SERIES_VALUES | Yes | TIME_SERIES_VALUES |
TIME_SERIES_VALUES | SORTED_LIST/RECORD_LIST | no | |
SORTED_LIST/RECORD_LIST | SORTED_LIST/RECORD_LIST | no |
Compare Operation
Compare Operation takes two expressions and compares their results.
The following table lists the compare operations supported by MQE.
Expression:
Expression1 <Compare-Operator> Expression2
Operator | Definition |
---|---|
> | greater than |
>= | greater than or equal |
< | less than |
<= | less than or equal |
== | equal |
!= | not equal |
The result of the compare operation is an int value:
- 1: true
- 0: false
For example:
Compare the service_resp_time
metric value if greater than 3000, if the service_resp_time
result is:
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": []},"values": [{"id": "1691658000000", "value": "2500", "traceID": null}, {"id": "1691661600000", "value": 3500, "traceID": null}]}]}}
}
we can use the following expression:
service_resp_time > 3000
and get result:
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": []},"values": [{"id": "1691658000000", "value": "0", "traceID": null}, {"id": "1691661600000", "value": 1, "traceID": null}]}]}}
}
Compare Operation Rules and Result Type
Same as the Binary Operation Rules.
Aggregation Operation
Aggregation Operation takes an expression and performs aggregate calculations on its results.
Expression:
<Aggregation-Operator>(Expression)
Operator | Definition | ExpressionResultType |
---|---|---|
avg | average the result | SINGLE_VALUE |
count | count number of the result | SINGLE_VALUE |
latest | select the latest non-null value from the result | SINGLE_VALUE |
sum | sum the result | SINGLE_VALUE |
max | select maximum from the result | SINGLE_VALUE |
min | select minimum from the result | SINGLE_VALUE |
For example:
If we want to query the average value of the service_cpm
metric, we can use the following expression:
avg(service_cpm)
Result Type
The different operators could impact the ExpressionResultType
, please refer to the above table.
Mathematical Operation
Mathematical Operation takes an expression and performs mathematical calculations on its results.
Expression:
<Mathematical-Operator>(Expression, parameters)
Operator | Definition | parameters | ExpressionResultType |
---|---|---|---|
abs | returns the absolute value of the result | follow the input expression | |
ceil | returns the smallest integer value that is greater or equal to the result | follow the input expression | |
floor | returns the largest integer value that is greater or equal to the result | follow the input expression | |
round | returns result round to specific decimal places | places : a positive integer specific decimal places of the result | follow the input expression |
For example:
If we want to query the average value of the service_cpm
metric in seconds,
and round the result to 2 decimal places, we can use the following expression:
round(service_cpm / 60 , 2)
Result Type
The different operators could impact the ExpressionResultType
, please refer to the above table.
TopN Operation
TopN Operation takes an expression and performs TopN calculation on its results.
Expression:
top_n(<metric_name>, <top_number>, <order>)
top_number
is the number of the top results, should be a positive integer.
order
is the order of the top results. The value of order
can be asc
or des
.
For example:
If we want to query the top 10 services with the highest service_cpm
metric value, we can use the following expression:
top_n(service_instance_cpm, 10, des)
Result Type
According to the type of the metric, the ExpressionResultType
of the expression will be SORTED_LIST
or RECORD_LIST
.
Relabel Operation
Relabel Operation takes an expression and replaces the label values with new label values on its results.
Expression:
relabel(Expression, _='<new_label_value_1>,...')
_
is the new label of the metric after the label is relabeled, the order of the new label values should be the same as the order of the label values in the input expression result.
For example:
If we want to query the service_percentile
metric with the label values 0,1,2,3,4
, and rename the label values to P50,P75,P90,P95,P99
, we can use the following expression:
relabel(service_percentile{_='0,1,2,3,4'}, _='P50,P75,P90,P95,P99')
Result Type
Follow the input expression.
AggregateLabels Operation
AggregateLabels Operation takes an expression and performs an aggregate calculation on its Labeled Value Metrics
results. It aggregates a group of TIME_SERIES_VALUES
into a single TIME_SERIES_VALUES
.
Expression:
aggregate_labels(Expression, parameter)
parameter | Definition | ExpressionResultType |
---|---|---|
avg | calculate avg value of a Labeled Value Metrics | TIME_SERIES_VALUES |
sum | calculate sum value of a Labeled Value Metrics | TIME_SERIES_VALUES |
max | select the maximum value from a Labeled Value Metrics | TIME_SERIES_VALUES |
min | select the minimum value from a Labeled Value Metrics | TIME_SERIES_VALUES |
For example:
If we want to query all Redis command total rates, we can use the following expression(total_commands_rate
is a metric which recorded every command rate in labeled value):
aggregate_labels(total_commands_rate, SUM)
Result Type
The ExpressionResultType of the aggregateLabels operation is TIME_SERIES_VALUES.
Logical Operation
ViewAsSequence Operation
ViewAsSequence operation represents the first not-null metric from the listing metrics in the given prioritized sequence(left to right). It could also be considered as a short-circuit
of given metrics for the first value existing metric.
Expression:
view_as_seq([<expression_1>, <expression_2>, ...])
For example:
if the first expression value is empty but the second one is not empty, it would return the result from the second expression.
The following example would return the content of the service_cpm metric.
view_as_seq(not_existing, service_cpm)
Result Type
The result type is determined by the type of selected not-null metric expression.
Expression Query Example
Labeled Value Metrics
service_percentile{_='0,1'}
The example result is:
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": [{"key": "_", "value": "0"}]},"values": [{"id": "1691658000000", "value": "1000", "traceID": null}, {"id": "1691661600000", "value": 2000, "traceID": null}]},{"metric": {"labels": [{"key": "_", "value": "1"}]},"values": [{"id": "1691658000000", "value": "2000", "traceID": null}, {"id": "1691661600000", "value": 3000, "traceID": null}]}]}}
}
If we want to transform the percentile value unit from ms
to s
the expression is:
service_percentile{_='0,1'} / 1000
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": [{"key": "_", "value": "0"}]},"values": [{"id": "1691658000000", "value": "1", "traceID": null}, {"id": "1691661600000", "value": 2, "traceID": null}]},{"metric": {"labels": [{"key": "_", "value": "1"}]},"values": [{"id": "1691658000000", "value": "2", "traceID": null}, {"id": "1691661600000", "value": 3, "traceID": null}]}]}}
}
Get the average value of each percentile, the expression is:
avg(service_percentile{_='0,1'})
{"data": {"execExpression": {"type": "SINGLE_VALUE","error": null,"results": [{"metric": {"labels": [{"key": "_", "value": "0"}]},"values": [{"id": null, "value": "1500", "traceID": null}]},{"metric": {"labels": [{"key": "_", "value": "1"}]},"values": [{"id": null, "value": "2500", "traceID": null}]}]}}
}
Calculate the difference between the percentile and the average value, the expression is:
service_percentile{_='0,1'} - avg(service_percentile{_='0,1'})
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": [{"key": "_", "value": "0"}]},"values": [{"id": "1691658000000", "value": "-500", "traceID": null}, {"id": "1691661600000", "value": 500, "traceID": null}]},{"metric": {"labels": [{"key": "_", "value": "1"}]},"values": [{"id": "1691658000000", "value": "-500", "traceID": null}, {"id": "1691661600000", "value": 500, "traceID": null}]}]}}
}
Calculate the difference between the service_resp_time
and the service_percentile
, if the service_resp_time
result is:
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": []},"values": [{"id": "1691658000000", "value": "2500", "traceID": null}, {"id": "1691661600000", "value": 3500, "traceID": null}]}]}}
}
The expression is:
service_resp_time - service_percentile{_='0,1'}
{"data": {"execExpression": {"type": "TIME_SERIES_VALUES","error": null,"results": [{"metric": {"labels": [{"key": "_", "value": "0"}]},"values": [{"id": "1691658000000", "value": "1500", "traceID": null}, {"id": "1691661600000", "value": "1500", "traceID": null}]},{"metric": {"labels": [{"key": "_", "value": "1"}]},"values": [{"id": "1691658000000", "value": "500", "traceID": null}, {"id": "1691661600000", "value": "500", "traceID": null}]}]}}
}
相关文章:
SkyWalking内置MQE语法
此文档出自SkyWalking官方git https://github.com/apache/skywalking docs/en/api/metrics-query-expression.md Metrics Query Expression(MQE) Syntax MQE is a string that consists of one or more expressions. Each expression could be a combination of one or more …...
Springboot2 Pandas Pyecharts 量子科技专利课程设计大作业
数据集介绍 1.背景 根据《中国科学:信息科学》期刊上的一篇文章,量子通信包括多种协议与应用类型: 基于量子隐形传态与量子存储中继等技术,可实现量子态信息传输,进而构建量子信息网络,已成为当前科研热点&…...
RabbitMQ里的几个重要概念
RabbitMQ中的一些角色: publisher:生产者consumer:消费者exchange个:交换机,负责消息路由,接受生产者发送的消息,把消息发送到一个或多个队列里queue:队列,存储消息virt…...
23. 图论 - 图的由来和构成
文章目录 图的由来图的构成Hi, 你好。我是茶桁。 从第一节课上到现在,我基本上把和人工智能相关的一些数学知识都教给大家了,终于来到我们人工智能数学的最后一个部分了,让我们从今天开始进入「图论」。 图论其实是一个比较有趣的领域,因为微积分其实更多的是对应连续型的…...
拼多多API接口解析,实现根据ID取商品详情
拼多多是一个流行的电商平台,它提供了API接口供开发者使用。要根据ID获取商品详情,您需要使用拼多多API接口并进行相应的请求。 以下是使用拼多多API接口根据ID获取商品详情的示例代码(使用Python编写): import requ…...
【JavaScript】解构
解构(Destructuring)是 JavaScript 中一种强大的语法特性,它允许你从数组或对象中提取值并赋值给变量,使代码更加简洁和易读。JavaScript 中有两种主要的解构语法:数组解构和对象解构。 数组解构 数组解构用于从数组…...
现代卷积网络实战系列2:训练函数、PyTorch构建LeNet网络
4、训练函数 4.1 调用训练函数 train(epochs, net, train_loader, device, optimizer, test_loader, true_value)因为每一个epoch训练结束后,我们需要测试一下这个网络的性能,所有会在训练函数中频繁调用测试函数,所有测试函数中所有需要的…...
rust特性
特性,也叫特质,英文是trait。 trait是一种特殊的类型,用于抽象某些方法。trait类似于其他编程语言中的接口,但又有所不同。 trait定义了一组方法,其他类型可以各自实现这个trait的方法,从而形成多态。 一、…...
TouchGFX之画布控件
TouchGFX的画布控件,在使用相对较小的存储空间的同时保持高性能,可提供平滑、抗锯齿效果良好的几何图形绘制。 TouchGFX 设计器中可用的画布控件: LineCircleShapeLine Progress圆形进度条 存储空间分配和使用 为了生成反锯齿效果良好的…...
STM32F103RCT6学习笔记2:串口通信
今日开始快速掌握这款STM32F103RCT6芯片的环境与编程开发,有关基础知识的部分不会多唠,直接实践与运用!文章贴出代码测试工程与测试效果图: 目录 串口通信实验计划: 串口通信配置代码: 测试效果图&#…...
Opencv-图像噪声(均值滤波、高斯滤波、中值滤波)
图像的噪声 图像的平滑 均值滤波 均值滤波代码实现 import cv2 as cv import numpy as np import matplotlib.pyplot as plt from pylab import mplmpl.rcParams[font.sans-serif] [SimHei]img cv.imread("dog.png")#均值滤波cv.blur(img, (5, 5))将对图像img进行…...
MasterAlign相机参数设置-增益调节
相机参数设置-曝光时间调节操作说明 相机参数的设置对于获取清晰、准确的图像至关重要。曝光时间是其中一个关键参数,它直接影响图像的亮度和清晰度。以下是关于曝光时间调节的详细操作步骤,以帮助您轻松进行设置。 步骤一:登录系统 首先&…...
9月22日,每日信息差
今天是2023年09月22日,以下是为您准备的14条信息差 第一、亚马逊将于2024年初在Prime Video中加入广告。Prime Video内容中的广告将于2024年初在美国、英国、德国和加拿大推出,随后晚些时候在法国、意大利、西班牙、墨西哥和澳大利亚推出 第二、中国移…...
Java版本企业工程项目管理系统源码+spring cloud 系统管理+java 系统设置+二次开发
工程项目各模块及其功能点清单 一、系统管理 1、数据字典:实现对数据字典标签的增删改查操作 2、编码管理:实现对系统编码的增删改查操作 3、用户管理:管理和查看用户角色 4、菜单管理:实现对系统菜单的增删改查操…...
Android studio中如何下载sdk
打开 file -> settings 这个页面, 在要下载的 SDK 前面勾上, 然后点 apply 在 platforms 中就可以看到下载好的 SDK: Android SDK目录结构详细介绍可以参考这篇文章: 51CTO博客- Android SDK目录结构...
STM32单片机中国象棋TFT触摸屏小游戏
实践制作DIY- GC0167-中国象棋 一、功能说明: 基于STM32单片机设计-中国象棋 二、功能介绍: 硬件组成:STM32F103RCT6最小系统2.8寸TFT电阻触摸屏24C02存储器1个按键(悔棋) 游戏规则: 1.有悔棋键&…...
【PHP图片托管】CFimagehost搭建私人图床 - 无需数据库支持
文章目录 1.前言2. CFImagehost网站搭建2.1 CFImagehost下载和安装2.2 CFImagehost网页测试2.3 cpolar的安装和注册 3.本地网页发布3.1 Cpolar临时数据隧道3.2 Cpolar稳定隧道(云端设置)3.3.Cpolar稳定隧道(本地设置) 4.公网访问测…...
CCITT 标准的CRC-16检验算法
/******该文件使用查表法计算CCITT 标准的CRC-16检验码,并附测试代码********/ #include #define CRC_INIT 0xffff //CCITT初始CRC为全1 #define GOOD_CRC 0xf0b8 //校验时计算出的固定结果值 /****下表是常用ccitt 16,生成式1021反转成8408后的查询表格****/ u…...
docker启动mysql服务
创建基础文件 mkdir mysql mkdir -p mysql/data获取默认的my.cnf docker run -name mysql -d -p 3306:3306 mysql:latest docker cp mysql:/etc/my.cnf ./vim mysql/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/8.1/en/se…...
Postman应用——Request数据导入导出
文章目录 导入请求数据导出请求数据导出Collection导出Environments 导出所有请求数据导出请求响应数据 Postman可以导入导出Request和Variable变量配置,可以通过文本方式(JOSN文本)或链接方式进行导入导出。 导入请求数据 可以通过JSON文件…...
十四、MySql的用户管理
文章目录 一、用户管理二、用户(一)用户信息(二)创建用户1.语法:2.案例: (三) 删除用户1.语法:2.示例: (四)修改用户密码1.语法&#…...
01.自动化交易综述
算法交易的概念: 利用自动化平台,执行预先设置的一系列规则完成交易行为。 算法交易的优势 1.历史数据评估 2.执行高效 3.无主观情绪输入 4.可度量评价 5.交易频率 算法交易的劣势 1.成本,成本低难以体现收益 2.技巧 算法交易流程 大前…...
基于SpringBoot的网上超市系统的设计与实现
目录 前言 一、技术栈 二、系统功能介绍 管理员功能实现 用户功能实现 三、核心代码 1、登录模块 2、文件上传模块 3、代码封装 前言 网络技术和计算机技术发展至今,已经拥有了深厚的理论基础,并在现实中进行了充分运用,尤其是基于计…...
国内首家!阿里云 Elasticsearch 8.9 版本释放 AI 搜索新动能
简介: 阿里云作为国内首家上线 Elasticsearch 8.9版本的厂商,在提供 Elasticsearch Relevance Engine™ (ESRE™) 引擎的基础上,提供增强 AI 的最佳实践与 ES 本身的混合搜索能力,为用户带来了更多创新和探索的可能性。 近年来&a…...
uniapp获取一周日期和星期
UniApp可以使用JavaScript中的Date对象来获取当前日期和星期几。以下是一个示例代码,可以获取当前日期和星期几,并输出在一周内的每天早上和晚上: // 获取当前日期和星期 let date new Date(); let weekdays ["Sunday", "M…...
QT之QListWidget的介绍
QListWidget常用成员函数 1、成员函数介绍2、例子显示图片和按钮的例子 1、成员函数介绍 1)QListWidget(QWidget *parent nullptr) 构造函数,创建一个新的QListWidget对象。 2)void addItem(const QString &label) 在列表末尾添加一个项目,项目标…...
数据结构--排序(1)
文章目录 排序概念直接插入排序希尔排序冒泡排序堆排序选择排序验证不同排序的运行时间 排序概念 排序指的是通过某一特征关键字(如信息量大小,首字母等)来对一连串的数据进行重新排列的操作,实现递增或者递减的数据排序。 稳定…...
【AI视野·今日NLP 自然语言处理论文速览 第三十七期】Thu, 21 Sep 2023
AI视野今日CS.NLP 自然语言处理论文速览 Thu, 21 Sep 2023 Totally 57 papers 👉上期速览✈更多精彩请移步主页 Daily Computation and Language Papers Chain-of-Verification Reduces Hallucination in Large Language Models Authors Shehzaad Dhuliawala, Mojt…...
高防服务器防护效果怎么样?
对于很多拥有在线业务的公司,数据是非常重要,如果遭到网络攻击会导致很严重的后果,所以很多公司选择高防服务器,那么高防服务器防护效果是怎么样的呢?今天就让小编带大家看一看吧! 弹性带宽。高防服务器一…...
tomcat架构概览
https://blog.csdn.net/ldw201510803006/article/details/119880100 前言 Tomcat 要实现 2 个核心功能: 处理 Socket 连接,负责网络字节流与 Request 和 Response 对象的转化。加载和管理 Servlet,以及具体处理 Request 请求。 因此 Tomc…...
网站怎么添加广告/怎么做竞价托管
首先在qq邮箱的设置中打开第一个pop3/SMTAP授权,并且记住授权码 from django.core.mail import send_mail subject 天天生鲜 message 正文 sender settings.EMAIL_FROM receiver [email] send_mail(subject,message,sender,receiver)在settings配置文件中写入 EMAIL_BACK…...
建设电子商务网站需要什么设备/seo的工作内容主要包括
2017年5月12日 09:57:48 星期五 最近接触了几天的composer, 不吹不黑, 简单说下用法吧 官方说要先用PHP命令行下载installer, 其实作用就是检测当前的PHP环境是否支持, 再一个就是自动下载composer.phar包 其实可以直接下载composer.phar放到某个地方 怎么跟你的PHP项目结合呢 …...
猪八戒做的网站怎么样/草莓永久地域网名入2022
1、mongodb 使用安全认证时,添加用户使用createUser,具体如下: 定义: 创建一个数据库新用户用db.createUser()方法,如果用户存在则返回一个用户重复错误。 语法: db.createUser(user, writeConcern) …...
建设网站需要哪些经营范围/百度seo营销公司
瀑布模型开发: 严格把软件项目的开发分隔成各个开发阶段:需求分析,要件定义,基本设计,详细设计,编码,单体测试,结合测试,系统测试等。使用里程碑的方式,严格定…...
用dz做网站怎么设置数据库/贴吧引流推广
代理模式 和 装饰器十分类似, 以如下图解释说明区别。 装饰者在之前介绍装饰模式的时候就说明了它是在被装饰者的功能基础上,附加新的功能,而且被装饰者的接口必定会被调用的情况下才选用装饰模式来解决问题; 而代理者是先判断是否需要执行被…...
澄迈网站制作/seo优化网页
对网络模型压缩有什么了解 网络模型压缩方法通常有剪枝、量化、蒸馏。 剪枝分为非结构化剪枝和结构化剪枝,非结构化剪枝指将部分不重要的参数置0,在一般的硬件设备中其实并不能加速,因为即使是0仍然要参与运算,结构化剪枝指将部分…...