Azure应用程序见解:如何格式化日期(和数字) [英] Azure Application Insights: How to format dates (and numbers)

查看:75
本文介绍了Azure应用程序见解:如何格式化日期(和数字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以一种汇总格式设置格式,以使其生成一种可读的可排序格式.我正在使用以下代码创建一个时间序列,以汇总几天内的请求数量:

I'm in need of formatting an aggregated date in such a way that it produces an readable and sortable format. I am creating a time series that aggregates the number of requests over a period of days using the following code:

let us_date = (t:datetime)
{ 
  strcat(    getmonth(t - 8h), "-",  dayofmonth(t - 8h))
};
requests
| project timestamp, client_IP, local_date = us_date(timestamp) 
| where timestamp >= now() -  30d  and timestamp <= now() + 1d
| summarize  uniqueUsers = dcount(client_IP) by usdate = us_date(timestamp)
| order by usdate desc

产生:

数据很好,但是由于格式化,排序顺序已关闭.

The data is fine, but due to the formatting the sort order is off.

要正确排序,应该看起来像05-09,但我看不到进行这种格式化的方法.

For this to sort correctly should look like 05-09, but I can't see a way to do this sort of formatting.

请注意,我可以执行以下操作,并以正确的顺序难看的格式获取数据:

Note that I can do the following and get the data in the right order but ugly format:

let us_date = (t:datetime)
{ 
  strcat(   getyear(t - 8h) , '-', getmonth(t - 8h), "-",  dayofmonth(t - 8h))
};
requests
| project timestamp, client_IP 
| where timestamp >= now() -  30d  and timestamp <= now() + 1d
| summarize  uniqueUsers = dcount(client_IP) by usdate = bin(timestamp - 8h,1d)
| order by usdate desc

但这会产生非常冗长的列表视图,并且还会将时间嵌入到图表中.

but this produces very verbose list view and also embeds the time into the chart.

有什么主意如何解决数字格式问题,或者如何在查询中获取另一个值以允许排序而不丢掉结果?

Any ideas how to address either the number formatting issue or how to get another value into the query to allow sorting without throwing off the results?

推荐答案

a)您可以在summarize之后的project更改列格式,列名或列顺序.

a) You can project after summarize to change the column format, column name or column order.

b)您可以格式化bin的结果.

b) You can format the result of bin.

这篇关于Azure应用程序见解:如何格式化日期(和数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆