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

[Improvement] Add streamalert_normalization as a top optional key automatically #1264

Open
chunyong-lin opened this issue Jun 22, 2020 · 0 comments

Comments

@chunyong-lin
Copy link
Contributor

Background

Based on the #1250, in order to cross join search original record between artifacts and original tables by record_id, it requires the original record to have streamalert_normalization field searchable, in which contains record_id. The streamalert_normalization field having following format,

{
    "record": {
        "region": "us-east-1",
        "detail": {
            "awsRegion": "us-west-2"
        }
    },
    "streamalert_normalization": {
        "streamalert_record_id": "abcdef0123456789",
        "region": [
            {
                "values": ["region_name"],
                "function": "AWS region"
            },
            {
                "values": ["region_name"],
                "function": "AWS region"
            }
        ]
    }
}

And the cross join search can be

SELECT artifacts.*,
         events.detail
FROM 
    (SELECT streamalert_record_id AS record_id,
         type,
         value
    FROM "PREFIX_streamalert"."artifacts"
    WHERE dt='2020-04-30-01'
            AND value='Root') AS artifacts
LEFT JOIN 
    (SELECT CAST(json_extract(streamalert_normalization,
         '$.streamalert_record_id') AS varchar) AS record_id, detail
    FROM "PREFIX_streamalert"."cloudwatch_events"
    WHERE dt='2020-04-30-01') AS events
    ON artifacts.record_id = events.record_id
LIMIT 10 

Desired Change

Right now, it requires users to add streamalert_normalization key as an optional top level key to the schema which has normalization configured. We think it is good idea to add this key to conf/schemas/*.json automatically during normalization build time.

But we still need to run build command to update the tables manually

python manage.py build --target "kinesis_firehose_*"
@chunyong-lin chunyong-lin added this to the 3.3.0 milestone Jun 22, 2020
@ryandeivert ryandeivert modified the milestones: 3.3.0, 3.4.0 Aug 4, 2020
@ryandeivert ryandeivert modified the milestones: 3.4.0, 4.1.0 Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants