[ABI 5.2] 接口数据源的body体怎么动态获取报表里面的参数

192
3

wsn123 数据达人Lv4

发表于2024-4-2 09:20

悬赏1

已解决

楼主


如图:
{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "xxx"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=asint(STRTODATE(datetostr(od(today(),'d-30'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }

上面红色字体需要在报表动态获取,如有三个参数,@a ,@b,@c  我想把xxx设置为,if(@a=1,@b,@c)这种逻辑,在接口数据源怎么写呢?

最近看过此主题的会员

esen_4VUGKRPH73WI

hhdtest

ESENSOFT官方技术支持

chestnut

wxw

esen_4O6N6U6ZN2

最佳答案
关帖总结:
问题:接口数据源的body,如何动态获取报表中的参数
如下示例如何根据报表参数控制value的值:
{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "xxx"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=asint(STRTODATE(datetostr(od(today(),'d-30'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }
解决方案:
{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "<#=@ci_name#>"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=if(@sj='3天',asint(STRTODATE(datetostr(od(today(),'d-3'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),if(@sj='7天',asint(STRTODATE(datetostr(od(today(),'d-7'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),asint(STRTODATE(datetostr(od(today(),'d-1'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())))#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }

3个回答

只看楼主

wsn123 数据达人Lv4

发表于2024-4-2 16:03

只看该作者

取消 关注该作者的回复

沙发

已经解决 :

{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "<#=@ci_name#>"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=if(@sj='3天',asint(STRTODATE(datetostr(od(today(),'d-3'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),if(@sj='7天',asint(STRTODATE(datetostr(od(today(),'d-7'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),asint(STRTODATE(datetostr(od(today(),'d-1'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())))#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }

可以做到 选择不同的时间  动态查询不同时间范围的数据   传不同的ci_name

chestnut 数据领袖Lv6

发表于2024-4-2 18:01

只看该作者

取消 关注该作者的回复

板凳

wsn123 发表于 2024-4-2 16:03
已经解决 :

{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "ta ...

厉害

chestnut 数据领袖Lv6

发表于2024-4-2 09:20

只看该作者

取消 关注该作者的回复

地板

关帖总结:
问题:接口数据源的body,如何动态获取报表中的参数
如下示例如何根据报表参数控制value的值:
{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "xxx"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=asint(STRTODATE(datetostr(od(today(),'d-30'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }
解决方案:
{     "metricNames": [         "cpu_usage", "memory_usage", "disk_usage"     ],     "tags": [         {             "key": "monitorObject",             "value": "<#=@ci_name#>"         },         {             "key": "namespace",             "value": "ElasticCloudServer"         }     ],     "startTime": <#=if(@sj='3天',asint(STRTODATE(datetostr(od(today(),'d-3'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),if(@sj='7天',asint(STRTODATE(datetostr(od(today(),'d-7'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime()),asint(STRTODATE(datetostr(od(today(),'d-1'),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())))#>,     "endTime": <#=asint(STRTODATE(datetostr(today(),'yyyy-mm-dd hh:nn:ss'),'yyyy-mm-dd hh:nn:ss').getTime())#>,     "downsample": "1s-mimmax",     "aggregator": "mimmax" }

登录后可回答问题,请登录注册

快速回复 返回顶部 返回列表

小时

全天响应

分钟

快速处理问题

工程师强势助力

明星产品
解决方案
联系合作

400咨询:400-0011-866

技术支持QQ:400-0011-866(工作日9:00-18:00)

产品建议邮箱yixin@esensoft.com

关注我们

扫TA学习更多干货

一对一专家交流

版权所有© 2006-2024 北京亿信华辰软件有限责任公司 京ICP备07017321号 京公网安备11010802016281号