Skip to content

Commit

Permalink
Adding routing.
Browse files Browse the repository at this point in the history
Signed-off-by: jzonthemtn <[email protected]>
  • Loading branch information
jzonthemtn committed Dec 18, 2024
1 parent 0459d46 commit e6773bd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
17 changes: 17 additions & 0 deletions osi/terraform/get-indexed-queries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

OPENSEARCH_ENDPOINT="search-osi-ubi-domain-pjju5yl7neorgz4jcsqhq5o7fq.us-east-1.es.amazonaws.com"

awscurl \
"https://${OPENSEARCH_ENDPOINT}/_cat/indices" \
-X GET \
--region us-east-1 \
--service es \
--profile mtnfog

awscurl \
"https://${OPENSEARCH_ENDPOINT}/ubi_queries/_search" \
-X GET \
--region us-east-1 \
--service es \
--profile mtnfog | jq
26 changes: 25 additions & 1 deletion osi/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,22 @@ resource "aws_osis_pipeline" "ubi_events_pipeline" {
ubi-pipeline:
source:
http:
path: "/ubi_events"
path: "/ubi"
processor:
- date:
from_time_received: true
destination: "@timestamp"
route:
- ubi-events: '/type == "event"'
- ubi-queries: '/type == "query"'
sink:
- opensearch:
hosts: ["https://${aws_opensearch_domain.opensearch_ubi.endpoint}"]
index: "ubi_events"
aws:
sts_role_arn: "${aws_iam_role.ubi.arn}"
region: "${data.aws_region.current.name}"
routes: [ubi-events]
- s3:
aws:
sts_role_arn: "${aws_iam_role.ubi.arn}"
Expand All @@ -157,6 +161,26 @@ resource "aws_osis_pipeline" "ubi_events_pipeline" {
event_collect_timeout: "60s"
codec:
ndjson:
routes: [ubi-events]
- opensearch:
hosts: ["https://${aws_opensearch_domain.opensearch_ubi.endpoint}"]
index: "ubi_queries"
aws:
sts_role_arn: "${aws_iam_role.ubi.arn}"
region: "${data.aws_region.current.name}"
routes: [ubi-queries]
- s3:
aws:
sts_role_arn: "${aws_iam_role.ubi.arn}"
region: "${data.aws_region.current.name}"
bucket: "${aws_s3_bucket.ubi_queries_events_bucket.id}"
object_key:
path_prefix: ubi_queries/
threshold:
event_collect_timeout: "60s"
codec:
ndjson:
routes: [ubi-queries]
EOT
max_units = 1
min_units = 1
Expand Down
4 changes: 2 additions & 2 deletions osi/terraform/send-event.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ awscurl \
--profile mtnfog \
-X POST \
-H "Content-Type: application/json" \
-d '[{"action_name": "click", "query_id": "00112233-4455-6677-8899-aabbccddeeff", "event_attributes": {"position": {"ordinal": 1}, "object": {"object_id": "1234", "object_id_field": "ean", "user_id": "abc"}}}]' \
https://${OSIS_PIPELINE_ENDPOINT_URL}/ubi_events
-d '[{"type": "event", "action_name": "click", "query_id": "00112233-4455-6677-8899-aabbccddeeff", "event_attributes": {"position": {"ordinal": 1}, "object": {"object_id": "1234", "object_id_field": "ean", "user_id": "abc"}}}]' \
https://${OSIS_PIPELINE_ENDPOINT_URL}/ubi
14 changes: 14 additions & 0 deletions osi/terraform/send-query.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

# pip install awscurl

OSIS_PIPELINE_ENDPOINT_URL="ubi-pipeline-xjmot6taz7mmcv76a36mlscgg4.us-east-1.osis.amazonaws.com"

awscurl \
--service osis \
--region us-east-1 \
--profile mtnfog \
-X POST \
-H "Content-Type: application/json" \
-d '[{"type": "query", "user_query": "computer", "query_id": "00112233-4455-6677-8899-aabbccddeeff"}]' \
https://${OSIS_PIPELINE_ENDPOINT_URL}/ubi

0 comments on commit e6773bd

Please sign in to comment.