如何在Seq中查询json文件?

发布于 2025-01-18 04:54:03 字数 1297 浏览 0 评论 0原文

我完全是新手的记录,但在SQL查询中很熟悉。我现在正在尝试Serilog和 seq 。我设法使用Serilog制作JSON行日志文件,并可以通过seqcli摄入-i命令将文件导入SEQ。我可以询问我的流,但以非常有限的方式。例如

select * from stream

,如下屏幕截图所示(示例文件是SEQ自己的日志):

“在此处输入图像说明”

我也可以查询@timestamp, @arrarived和@data colums,

select @Timestamp, @Arrived, @Data from stream

但我不知道该如何到达@Data内部的属性。我期望类似

select @Timestamp, @Arrived, @Data.@[email protected] from stream

,但这不起作用。我如何列出例如@data。 @

更新

有趣的是,SEQ显示了文件的原始内容。这部分: 如下所示,在原始文件中查看:

{“@t”:“ 2022-03-30T14:24:49.0999009z”,“@mt”:“创建{userId}”,“ userId”,“ user-admin”}

:会期望

select @mt.UserId from stream

或一些类似的查询工作。

I'm completely new in logging but familiar in SQL queries. I'm now experimenting with Serilog and Seq. I managed to make JSON lines log file with Serilog and could import the file into Seq by the seqcli ingest -i command. I can query my stream but in a very limited way. E.g.

select * from stream

works as shown on the screenshot below (the example file is Seq's own log):

enter image description here

I can also query the @Timestamp, @Arrived and @Data colums as

select @Timestamp, @Arrived, @Data from stream

but I don't know how can I reach the properties inside @Data. I expect something like

select @Timestamp, @Arrived, @Data.@[email protected] from stream

but this doesn't work. How can I list for example the @Data.@[email protected] values?

UPDATE

Interesting that Seq shows something else than the original content of the file. This part:
enter image description here
looks in the original file simply as this:

{"@t":"2022-03-30T14:24:49.0999009Z","@mt":"Creating default workspace for {UserId}","UserId":"user-admin"}

so, regarding this, I would expect

select @mt.UserId from stream

or some similar query work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2025-01-25 04:54:03

使用seqcli摄入导入时,您需要指定-JSON,例如:

seqcli ingest -i ./some.log --json

When importing using seqcli ingest, you need to specify --json, e.g.:

seqcli ingest -i ./some.log --json
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文