如何管理 loki 中日志文本中未找到的元素的标签基数

发布于 2025-01-20 05:50:37 字数 675 浏览 3 评论 0原文

我的系统中有作业正在登录到文件中,其中每个不同的作业输出都登录到一个以作业ID命名的不同文件。

系统中的大多数操作都是通过这些作业执行的,因此我希望其中有很多。

我的第一种方法是使用文件名模式标记日志,该模式正常,但会为每个作业ID产生一个流。

来自loki 有关标签基础的文档我知道我应该努力最小化索引的原木的基础性,这使我遇到了问题。

我希望用户能够

  • 通过标签{job =“ myjob”,job_id =“ 1234”}
  • 或通过文本搜索{job = {job = { “ myjob”} | =“ job_id = 1234”(这是避免高索引基数的推荐方法)。

鉴于作业ID是从日志文件的名称而不是日志文本派生的,我应该如何处理?

是否可以人为地将作业ID添加到所有提取的日志线文本中?如果是这样,那是一个好习惯吗?

标签心脏如何随着时间的推移而产生?如 - 如果仅在有限的时间范围内存在标签值(例如工作ID,仅限于该工作)是否仍然被视为不良习惯?

I have jobs in my system being logged into files, where each distinct job output is logged into a different file, named after the job's id.

Most of the actions in the system are executed through these jobs so I'm expecting a high number of them.

My first approach was to label the logs using the file name pattern, which works fine but will produce a stream for each job id.

From the Loki documentation about label fundamentals I understand I should be striving to minimize the cardinality of the logs being indexed, which leaves me with a problem.

The job id is something I want users to be able to query by,

  • either through the label {job="myjob", job_id="1234"}
  • or through a text search {job="myjob"} |= "job_id=1234" (which is the recommended way to avoid high index cardinality).

Given that the job id is derived from the log file's name and not the log text, how should I approach this?

Is it possible to artificially add the job id to all extracted log line texts? if so, is that a good practice?

How is label cardinality effected over time? as in - if a label value exists only for a limited time span (like a job id, which is limited to that job) is this still considered a bad practice?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文