influxdb - Influxdb 从测量中选择最后一个特定值
问题描述
我的詹金斯将所有测试的结果发送到一个 influxdb 测量,测量的值为 test_name status 等,当测量中的状态值为 0 时,表示测试失败,如果为 1,则测试通过,我想如果他的状态为 0,请选择詹金斯发送给 influx 的最后一个特定的 test_name,如果他的状态为 0,则显示 test_name,如果他的状态为 1,请不要显示。
SELECT last(test_name) FROM db WHERE testname=example AND status = 0
此命令向我显示最后一个示例 testname,即 status 为 0,但我需要其他内容。
我需要他检查他的最新状态,如果他是 1,请不要给我任何回报,
解决方案
使用以下查询获取根据给定条件插入的最后一个值:
select test_name from yourmeasurement order by time desc where testname='example' and status=0 limit 1
这里需要按订单中的数据descending
排序,然后选择前1个查询。由于数据插入是时间序列,因此您无需提供时间,因为它是自动进行的。
推荐阅读
- flutter - Flutter - 当我推送的页面被后退按钮弹出时如何得到通知?
- windows - 如何在 Windows 上创建每用户服务?
- scheduled-tasks - 为什么即使我通过设置 `spark.sql.shuffle.partitions` 更改默认配置,结构化流式处理的阶段大多有 200 个任务?
- openssl - 匿名密码不适用于 OpenSSL1.1.1-D
- amazon-web-services - AWS Glue Cloudformation 排除模式 排除:字符串
- java - 动态根元素 JAXB?
- python - 如何在 python 中的 elasticsearch 中索引大型 json 响应?使用 Elasticsearch DSL
- javascript - React-parent 组件正在输入子项的值 1 个字符丢失
- javascript - 当 Store 在 Reducer 中发生更改时,useSelector 不会更新。ReactJS Redux
- android - 如何从apk文件中获取url?