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

aes-siem-es-loader [ERROR] KeyError: '@id' #464

Open
iizuka-1112 opened this issue Dec 6, 2024 · 0 comments
Open

aes-siem-es-loader [ERROR] KeyError: '@id' #464

iizuka-1112 opened this issue Dec 6, 2024 · 0 comments

Comments

@iizuka-1112
Copy link

背景

JSONファイルのdetail.rtという値を削除してOpensearchに取り込むことを目標としております。
取り込むJSONファイル内の指定したキーを削除した状態でOpensearchに取り込もうとしたところ、”@idがない”とエラーが出力されました。

user.iniのscript_ecs = detail.rtをコメントアウトするとOpensearchに取り込むこと自体はできてはいるのですが、フィールドの型がタイムスタンプではあるのですが型が定まっていない為、除外してからOpensearchに取り込もうとしていました。

目標

下記記載のJSON加工後データイメージのように指定したフィールドを除外したいです。
ご協力お願いいたします。

提供情報

設定を変更している箇所はuser.ini、siem\sf_hogehoge.py(除外用のスクリプト)のみとなります。

JSON加工前データイメージ

{
"detectionTime": "2024-12-02T23:23:21Z",
"endpoint": {
"name": "TEST1-PC",
"guid": "12345678-9abc-def-ghij-000000000000",
"ips": [
"10.1.1.1"
]
},
"detail": {
"endpointHostName": "TEST1-PC",
"endpointIp": [
"10.1.1.1"
],
"tags": [
"0000.0001"
],
"rt": "2024-12-02T23:23:21+00:00",
"rtDate": "2024-12-02"
}
}

JSON加工後データイメージ

{
"detectionTime": "2024-12-02T23:23:21Z",
"endpoint": {
"name": "TEST1-PC",
"guid": "12345678-9abc-def-ghij-000000000000",
"ips": [
"10.1.1.1"
]
},
"detail": {
"endpointHostName": "TEST1-PC",
"endpointIp": [
"10.1.1.1"
],
"tags": [
"0000.0001"
],
"rtDate": "2024-12-02"
}
}

user.ini

[hogehoge]
script_ecs = detail.rt

エラー本文

[ERROR] KeyError: '@id'
Traceback (most recent call last):
File "/var/task/aws_lambda_powertools/metrics/provider/base.py", line 204, in decorate
response = lambda_handler(event, context, *args, **kwargs)
File "/var/task/aws_lambda_powertools/logging/logger.py", line 451, in decorate
return lambda_handler(event, context, *args, **kwargs)
File "/var/task/index.py", line 442, in decorator
return func(*args, **kwargs)
File "/var/task/index.py", line 515, in lambda_handler
batch_item_failures = main(event, context)
File "/var/task/index.py", line 531, in main
process_record(record)
File "/var/task/index.py", line 589, in process_record
bulkloads_into_opensearch(es_entries, collected_metrics))
File "/var/task/index.py", line 326, in bulkloads_into_opensearch
for data in es_entries:
File "/var/task/index.py", line 270, in get_es_entries
action_meta = {'index': {'_index': indexname, '_id': logparser.doc_id}}
File "/var/task/siem/init.py", line 615, in doc_id
return self.__logdata_dict['@id']

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

No branches or pull requests

1 participant