Skip to content

Commit 84a00f3

Browse files
authored
Add CloudFront queries for integrations and integration table bug fix (#1687)
* initial commit for adding cloudfront integrations Signed-off-by: Sean Li <[email protected]> * adding queries and fixing bug in integrations table Signed-off-by: Sean Li <[email protected]> * updating ndjson, changing options Signed-off-by: Sean Li <[email protected]> * removing OSD bump Signed-off-by: Sean Li <[email protected]> * updating tests Signed-off-by: Sean Li <[email protected]> * updating MV name Signed-off-by: Sean Li <[email protected]> --------- Signed-off-by: Sean Li <[email protected]>
1 parent 72283be commit 84a00f3

File tree

6 files changed

+121
-9
lines changed

6 files changed

+121
-9
lines changed

server/adaptors/integrations/__data__/repository/aws_cloudfront/assets/aws_cloudfront-1.0.0.ndjson

+5-5
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CREATE MATERIALIZED VIEW {table_name}__mview AS
2+
SELECT
3+
to_timestamp(trim(BOTH '[]' FROM concat(date, ' ', time)), 'yyyy-MM-dd HH:mm:ss') AS `@timestamp`,
4+
c_ip AS `aws.cloudfront.c-ip`,
5+
c_port as `aws.cloudfront.c-port`,
6+
cs_cookie as `aws.cloudfront.cs-cookie`,
7+
cs_host as `aws.cloudfront.cs-host`,
8+
cs_referrer as `aws.cloudfront.cs-referer`,
9+
cs_user_agent as `aws.cloudfront.cs-user-agent`,
10+
cs_bytes as `aws.cloudfront.cs-bytes`,
11+
cs_method as `aws.cloudfront.cs-method`,
12+
cs_protocol as `aws.cloudfront.cs-protocol`,
13+
cs_protocol_version as `aws.cloudfront.cs-protocol-version`,
14+
cs_uri_query as `aws.cloudfront.cs-uri-query`,
15+
cs_uri_stem as `aws.cloudfront.cs-uri-stem`,
16+
fle_encrypted_fields as `aws.cloudfront.fle-encrypted-fields`,
17+
fle_status as `aws.cloudfront.fle-status`,
18+
sc_bytes as `aws.cloudfront.sc-bytes`,
19+
sc_content_len as `aws.cloudfront.sc-content-len`,
20+
sc_content_type as `aws.cloudfront.sc-content-type`,
21+
sc_range_end as `aws.cloudfront.sc-range-end`,
22+
sc_range_start as `aws.cloudfront.sc-range-start`,
23+
sc_status as `aws.cloudfront.sc-status`,
24+
ssl_cipher as `aws.cloudfront.ssl-cipher`,
25+
ssl_protocol as `aws.cloudfront.ssl-protocol`,
26+
time_taken as `aws.cloudfront.time-taken`,
27+
time_to_first_byte as `aws.cloudfront.time-to-first-byte`,
28+
x_edge_detailed_result_type as `aws.cloudfront.x-edge_detailed-result-type`,
29+
x_edge_location as `aws.cloudfront.x-edge-location`,
30+
x_edge_request_id as `aws.cloudfront.x-edge-request-id`,
31+
x_edge_result_type as `aws.cloudfront.x-edge-result-type`,
32+
x_edge_response_result_type as `aws.cloudfront.x-edge-response-result-type`,
33+
x_forwarded_for as `aws.cloudfront.x-forwarded-for`,
34+
x_host_header as `aws.cloudfront.x-host-header`
35+
FROM
36+
{table_name}
37+
WITH (
38+
auto_refresh = true,
39+
checkpoint_location = '{s3_checkpoint_location}',
40+
watermark_delay = '1 Minute',
41+
extra_options = '{ "{table_name}": { "maxFilesPerTrigger": "10" }}'
42+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
CREATE EXTERNAL TABLE IF NOT EXISTS {table_name} (
2+
`date` STRING,
3+
time STRING,
4+
x_edge_location STRING,
5+
sc_bytes BIGINT,
6+
c_ip STRING,
7+
cs_method STRING,
8+
cs_host STRING,
9+
cs_uri_stem STRING,
10+
sc_status INT,
11+
cs_referrer STRING,
12+
cs_user_agent STRING,
13+
cs_uri_query STRING,
14+
cs_cookie STRING,
15+
x_edge_result_type STRING,
16+
x_edge_request_id STRING,
17+
x_host_header STRING,
18+
cs_protocol STRING,
19+
cs_bytes BIGINT,
20+
time_taken FLOAT,
21+
x_forwarded_for STRING,
22+
ssl_protocol STRING,
23+
ssl_cipher STRING,
24+
x_edge_response_result_type STRING,
25+
cs_protocol_version STRING,
26+
fle_status STRING,
27+
fle_encrypted_fields INT,
28+
c_port INT,
29+
time_to_first_byte FLOAT,
30+
x_edge_detailed_result_type STRING,
31+
sc_content_type STRING,
32+
sc_content_len BIGINT,
33+
sc_range_start BIGINT,
34+
sc_range_end BIGINT
35+
)
36+
USING csv
37+
LOCATION '{s3_bucket_location}'
38+
OPTIONS ( sep='\t' )
39+
TBLPROPERTIES ( 'skip.header.line.count'='2' );

server/adaptors/integrations/__data__/repository/aws_cloudfront/aws_cloudfront-1.0.0.json

+30-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Analyze access logs for Amazon CloudFront.",
66
"license": "Apache-2.0",
77
"type": "logs-aws_cloudfront",
8-
"labels": ["Observability", "Logs", "AWS", "Cloud"],
8+
"labels": ["Observability", "Logs", "AWS", "Cloud", "Flint S3"],
99
"author": "OpenSearch",
1010
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_cloudfront/info",
1111
"statics": {
@@ -20,6 +20,20 @@
2020
}
2121
]
2222
},
23+
"workflows": [
24+
{
25+
"name": "queries",
26+
"label": "Queries (recommended)",
27+
"description": "Tables and pre-written queries for quickly getting insights on your data.",
28+
"enabled_by_default": true
29+
},
30+
{
31+
"name": "dashboards",
32+
"label": "Dashboards & Visualizations",
33+
"description": "Dashboards and indices that enable you to easily visualize important metrics.",
34+
"enabled_by_default": false
35+
}
36+
],
2337
"components": [
2438
{
2539
"name": "aws_cloudfront",
@@ -43,7 +57,21 @@
4357
"name": "aws_cloudfront",
4458
"version": "1.0.0",
4559
"extension": "ndjson",
46-
"type": "savedObjectBundle"
60+
"type": "savedObjectBundle",
61+
"workflows": ["dashboards"]
62+
},
63+
{
64+
"name": "create_table",
65+
"version": "1.0.0",
66+
"extension": "sql",
67+
"type": "query"
68+
},
69+
{
70+
"name": "create_mv",
71+
"version": "1.0.0",
72+
"extension": "sql",
73+
"type": "query",
74+
"workflows": ["dashboards"]
4775
}
4876
],
4977
"sampleData": {

server/adaptors/integrations/__test__/manager.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ describe('IntegrationsKibanaBackend', () => {
196196

197197
const result = await backend.getIntegrationInstances();
198198

199-
expect(mockSavedObjectsClient.find).toHaveBeenCalledWith({ type: 'integration-instance' });
199+
expect(mockSavedObjectsClient.find).toHaveBeenCalledWith({
200+
type: 'integration-instance',
201+
perPage: 1000,
202+
});
200203
expect(result).toEqual({
201204
total: findResult.total,
202205
hits: savedObjects.map((obj) => ({ id: obj.id, ...obj.attributes })),

server/adaptors/integrations/integrations_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class IntegrationsManager implements IntegrationsAdaptor {
9393
_query?: IntegrationInstanceQuery
9494
): Promise<IntegrationInstancesSearchResult> => {
9595
addRequestToMetric('integrations', 'get', 'count');
96-
const result = await this.client.find({ type: 'integration-instance' });
96+
const result = await this.client.find({ type: 'integration-instance', perPage: 1000 });
9797
return Promise.resolve({
9898
total: result.total,
9999
hits: result.saved_objects?.map((x) => ({

0 commit comments

Comments
 (0)