Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: processor_split_char SourceKey 无法使用tags数据中log.file.path信息 #1979

Open
jasonchoi517 opened this issue Dec 18, 2024 · 6 comments
Labels
question Further information is requested

Comments

@jasonchoi517
Copy link

Before asking a question, please first consider:


输出到Kafka信息如下

{
  "contents": {
    "__file_offset__": "25879278",
    "bodyTime": "2024-11-04 10:30:49.786",
    "class": "com.fenqile.abacus.service.engine.ComputingServiceImpl",
    "content": "2024-11-04 10:30:49.786|27659|",
    "env": "prod",
    "logLevel": "INFO",
    "method": "computing",
    "traceID": "xxxxxx",
    "uid": "37116931"
  },
  "tags": {
    "__inode__": "32212255297",
    "host.ip": "xxx.xxx.xxx.xxx",
    "host.name": "localhost",
    "log.file.path": "/data/product/logs/ln-apps/java-test-01-bbf6959c-dffbj/192.168.11.12/flume/java-test/info.log"
  },
  "time": 1734417281
}

yaml文件:

enable: true
inputs:

  • Type: input_file
    FilePaths:
    • /data/product/logs/ln-apps///flume//.log
      processors:
  • Type: processor_split_char
    SourceKey: 这里怎么引用 tags里log.file.path呢?
    SplitSep: "|"
    SplitKeys:

目标我需要解析文件路径中IP地址(192.168.11.12)和应用名称(java-test)

@jasonchoi517 jasonchoi517 added the question Further information is requested label Dec 18, 2024
@Takuka0311
Copy link
Collaborator

可以查看我们的日志协议,上述需求的字段是在tags中的:https://open.observability.cn/project/ilogtail/developer-guide-log-protocol-protocol-spec-sls/#_top

目前的processor都还不支持直接处理tags

@jasonchoi517
Copy link
Author

你好,是否可以将tags数据,写入contexts里呢?

@Takuka0311
Copy link
Collaborator

Takuka0311 commented Dec 18, 2024

文件路径实际上是保存在contents里的,可以试一下“tag:path”字段,但是ip保存的位置确实无法获取。看到您用的kafka插件,或许可以用这个来看看(这个是输出测打平了,但是processor还是处理不了的):

https://open.observability.cn/project/ilogtail/plugins-flusher-kafka-v2/#%E6%95%B0%E6%8D%AE%E5%B9%B3%E9%93%BA

@jasonchoi517
Copy link
Author

jasonchoi517 commented Dec 18, 2024

你好,2.0.7 contents 没有"tag:path "字段
{
"contents": {
"file_offset": "25879278",
"bodyTime": "2024-11-04 10:30:49.786",
"class": "com.fenqile.abacus.service.engine.ComputingServiceImpl",
"content": "2024-11-04 10:30:49.786|27659|",
"env": "prod",
"logLevel": "INFO",
"method": "computing",
"traceID": "xxxxxx",
"uid": "37116931"
},
"tags": {
"inode": "32212255297",
"host.ip": "xxx.xxx.xxx.xxx",
"host.name": "localhost",
"log.file.path": "/data/product/logs/ln-apps/java-test-01-bbf6959c-dffbj/192.168.11.12/flume/java-test/info.log"
},
"time": 1734417281
}
哪个版本,文件路径实际上是保存在contents里的呢? 还是要配置哪个参数才会显示出来。

@pz9042
Copy link

pz9042 commented Dec 23, 2024

你好,2.0.7 contents 没有"tag:path "字段 { "contents": { "file_offset": "25879278", "bodyTime": "2024-11-04 10:30:49.786", "class": "com.fenqile.abacus.service.engine.ComputingServiceImpl", "content": "2024-11-04 10:30:49.786|27659|", "env": "prod", "logLevel": "INFO", "method": "computing", "traceID": "xxxxxx", "uid": "37116931" }, "tags": { "inode": "32212255297", "host.ip": "xxx.xxx.xxx.xxx", "host.name": "localhost", "log.file.path": "/data/product/logs/ln-apps/java-test-01-bbf6959c-dffbj/192.168.11.12/flume/java-test/info.log" }, "time": 1734417281 } 哪个版本,文件路径实际上是保存在contents里的呢? 还是要配置哪个参数才会显示出来。

解决了吗?我也有这个需求,想从file path 提取渠道信息,processer看文档,SourceKey只能是content,content里没有文件路径

@Takuka0311
Copy link
Collaborator

@Abingcbc 这个或许他比较清楚一些

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants