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

[cloudflare_logpush] Initial Release for the Cloudflare Logpush #3643

Merged
merged 13 commits into from
Sep 9, 2022

Conversation

vinit-chauhan
Copy link
Contributor

@vinit-chauhan vinit-chauhan commented Jul 4, 2022

What does this PR do?

  • Generated the skeleton of the Cloudflare Log Push integration package.
  • Added a data stream.
  • Added data collection logic to the data stream.
  • Added the ingest pipeline for the data stream.
  • Mapped fields according to the ECS schema and added Fields metadata in the appropriate yml files
  • Added dashboards and visualizations.
  • Added test for pipeline for the data stream.
  • Added system test cases for the data stream.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • If I'm introducing a new feature, I have modified the Kibana version constraint in my package's manifest.yml file to point to the latest Elastic stack release (e.g. ^7.17.0 || ^8.0.0).

How to test this PR locally

  • Clone integrations repo.
  • Install elastic package locally.
  • Start elastic stack using elastic-package.
  • Move to integrations/packages/cloudflare_logpush directory.
  • Run the following command to run tests.

elastic-package test

Related issues

Screenshots

image
image
image (3)
image (4)
image (5)
image (6)

@elasticmachine
Copy link

elasticmachine commented Jul 4, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-09-06T08:09:52.171+0000

  • Duration: 20 min 18 sec

Test stats 🧪

Test Results
Failed 0
Passed 44
Skipped 0
Total 44

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@elasticmachine
Copy link

elasticmachine commented Jul 4, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (7/7) 💚
Files 100.0% (7/7) 💚 2.89
Classes 100.0% (7/7) 💚 2.89
Methods 100.0% (89/89) 💚 10.389
Lines 94.37% (2380/2522) 👍 2.619
Conditionals 100.0% (0/0) 💚

@legoguy1000
Copy link
Contributor

Why a separate integration instead of just adding the new datastreams/inputs to the original one?

@vinit-chauhan vinit-chauhan changed the title Initial Release for the Cloudflare Logpush [cloudflare_logpush] Initial Release for the Cloudflare Logpush Jul 18, 2022
@jamiehynds
Copy link

Why a separate integration instead of just adding the new datastreams/inputs to the original one?

Hey @legoguy1000 - we explored the possibility of adding Logpush to your Logpull integration, but there are several event types that are only supported by Log Push and it would be tricky to align content such as dashboards within a single integration. We're going to update the Log Pull integration to make it clearer that the integration is based on Logpull.

@legoguy1000
Copy link
Contributor

I get the issue with the additional datasets though perhaps since the only 2 datasets in the original cloudflare integration are http and audit logs. My thought is add the httpjson inputs to the new audit and http event data streams and then deprecate the original integration. That way u may not have a conflict and u only have to maintain a single integration/pipelines/dashboards.... going forward.

@CyberTaoFlow
Copy link

bump!

@r00tu53r
Copy link
Contributor

@vinit-elastic it would be useful to know a benchmark on the number of events that can be pumped to ES per second (EPS) with this input (say on a single node cluster). Would you be able to run a test check the performance ?

@vinit-chauhan
Copy link
Contributor Author

vinit-chauhan commented Jul 22, 2022

Hey @r00tu53r

Elastic-Agent is running on one machine, Elasticsearch and Kibana on another machine.

Configuration of the machine in which Elastic-agent is running:
CPU - 2
No of Cores - 1
RAM - 8GB

When no of the workers are set to 5 (Default), then:
Ingestion rate = 46 events/sec
The size of each message is approx = 0.8 KB
Therefore, the volume of data ingested in one day would be around 3.17 GB

When no of the workers are set to 100, then:
Ingestion rate = 440 events/sec
The size of each message is approx = 0.8 KB
Therefore, the volume of data ingested in one day would be around 30 GB

@jamiehynds
Copy link

@vinit-elastic Logpush delivers logs in less than one minute with batches of no more than 100,000 records per file. Based on the ingestion rate of 440 EPS with 100 quarters, that only gets us to ~25% of what Cloudflare could send in a minute. Do we know if there's additional workers we can add or other variables configuration to ensure we can support that rate of ingestion?

@vinit-chauhan
Copy link
Contributor Author

Hey @jamiehynds - The low ingestion rate may be due to the hardware configuration. Moreover, we have kept the number of workers as a configurable parameter so that if the data rate is huge for some users, they can tweak the number per the requirement.

@RichiCoder1
Copy link

RichiCoder1 commented Jul 29, 2022

This looks awesome! Is there any chance support for the queue form of aws-s3 could be supported too? That's primarily how we have these setup today, and is much more efficient.


### Audit Logs

- Default port for HTTP Endpoint: _9560_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we require more than one port to be exposed to the Internet. I've opened a proposal issue to discuss a possible solution in elastic/beats#32578.

@@ -0,0 +1,26 @@
bucket_arn: {{bucket_arn}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the integration should be capable of using SQS notification and S3 polling. Could we create two separate input configurations like aws-s3-polling.yml.hbs and aws-s3-sqs.yml.hbs? If they are separate I think that would be easier to maintain and to configure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you combined everything into one file, did my recommendation to use aws-s3-polling.yml.hbs and aws-s3-sqs.yml.hbs not work? What problems did you encounter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We started with keeping a separate file for S3 Polling and SQS ( aws-s3-polling.yml.hbs and aws-s3-sqs.yml.hbs ). However, while doing so, we observed the following behavior.

Though the hbs files were different, the input type was the same input: aws-s3. So, the toggle for both S3 Pooling and S3 SQS was not working properly. So, whenever a user changes the state of one toggle to collect data for only one of the input types, either S3 Pooling or S3 SQS, other one starts automatically. That's the reason why we kept the combined everything into one file.

Moreover, to avoid confusion we've added an indicator in the description of both (S3-Pooling ->[S3] and S3-SQS ->[SQS]) to make it more user-friendly. Now, the users only need to enable the toggle button (Collect logs via S3 Bucket) in order to collect the logs through S3-Polling input and disable it for SQS.

packages/cloudflare_logpush/_dev/build/docs/README.md Outdated Show resolved Hide resolved
packages/cloudflare_logpush/changelog.yml Outdated Show resolved Hide resolved
@vinit-chauhan
Copy link
Contributor Author

/test

Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>

## Overview

The [Cloudflare Logpush](https://www.cloudflare.com/) integration allows you to monitor Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics and Spectrum Event Logs. Cloudflare is content delivery network and DDoS mitigation company. Cloudflare is a global network designed to make everything you connect to the Internet secure, private, fast, and reliable. Secure your websites, APIs, and Internet applications. Protect corporate networks, employees, and devices. Write and deploy code that runs on the network edge.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The [Cloudflare Logpush](https://www.cloudflare.com/) integration allows you to monitor Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics and Spectrum Event Logs. Cloudflare is content delivery network and DDoS mitigation company. Cloudflare is a global network designed to make everything you connect to the Internet secure, private, fast, and reliable. Secure your websites, APIs, and Internet applications. Protect corporate networks, employees, and devices. Write and deploy code that runs on the network edge.
The [Cloudflare Logpush](https://www.cloudflare.com/) integration allows you to monitor Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics and Spectrum Event Logs. Cloudflare is a content delivery network and DDoS mitigation company. Cloudflare provides a network designed to make everything you connect to the Internet secure, private, fast, and reliable; secure your websites, APIs, and Internet applications; protect corporate networks, employees, and devices; and write and deploy code that runs on the network edge.

Comment on lines 7 to 11
The Cloudflare Logpush integration can be used in three different modes to collect data:
- HTTP Endpoint mode - Cloudflare pushes logs directly to an HTTP endpoint hosted by your Elastic Agent
- AWS S3 polling mode - Cloudflare writes data to S3 and Elastic Agent polls the S3 bucket by listing its contents and reading new files
- AWS S3 SQS mode - Cloudflare writes data to S3, S3 pushes a new object notification to SQS, Elastic Agent receives the notification from SQS, and then reads the S3 object. Multiple Agents can be used in this mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Cloudflare Logpush integration can be used in three different modes to collect data:
- HTTP Endpoint mode - Cloudflare pushes logs directly to an HTTP endpoint hosted by your Elastic Agent
- AWS S3 polling mode - Cloudflare writes data to S3 and Elastic Agent polls the S3 bucket by listing its contents and reading new files
- AWS S3 SQS mode - Cloudflare writes data to S3, S3 pushes a new object notification to SQS, Elastic Agent receives the notification from SQS, and then reads the S3 object. Multiple Agents can be used in this mode.
The Cloudflare Logpush integration can be used in three different modes to collect data:
- HTTP Endpoint mode - Cloudflare pushes logs directly to an HTTP endpoint hosted by your Elastic Agent.
- AWS S3 polling mode - Cloudflare writes data to S3 and Elastic Agent polls the S3 bucket by listing its contents and reading new files.
- AWS S3 SQS mode - Cloudflare writes data to S3, S3 pushes a new object notification to SQS, Elastic Agent receives the notification from SQS, and then reads the S3 object. Multiple Agents can be used in this mode.

- AWS S3 SQS mode - Cloudflare writes data to S3, S3 pushes a new object notification to SQS, Elastic Agent receives the notification from SQS, and then reads the S3 object. Multiple Agents can be used in this mode.


For example, you could use the data from this integration to know about which websites have the highest traffic, which areas have the highest network traffic, or mitigation statistics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, you could use the data from this integration to know about which websites have the highest traffic, which areas have the highest network traffic, or mitigation statistics.
For example, you could use the data from this integration to know which websites have the highest traffic, which areas have the highest network traffic, or observe mitigation statistics.


## Data streams

The Cloudflare Logpush integration collects logs for seven types of events: Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics and Spectrum Event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Cloudflare Logpush integration collects logs for seven types of events: Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics and Spectrum Event.
The Cloudflare Logpush integration collects logs for seven types of events: Audit, DNS, Firewall Event, HTTP Request, NEL Report, Network Analytics, and Spectrum Event.

value: [authentication]
- date:
field: json.When
if: ctx.json?.When != null && ctx.json?.When != ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: ctx.json?.When != null && ctx.json?.When != ''
if: ctx.json?.When != null && ctx.json.When != ''

ignore_failure: true
- date:
field: json.ConnectTimestamp
if: ctx.json?.ConnectTimestamp != null && ctx.json?.ConnectTimestamp != ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: ctx.json?.ConnectTimestamp != null && ctx.json?.ConnectTimestamp != ''
if: ctx.json?.ConnectTimestamp != null && ctx.json.ConnectTimestamp != ''

value: '{{{_ingest.on_failure_message}}}'
- date:
field: json.DisconnectTimestamp
if: ctx.json?.DisconnectTimestamp != null && ctx.json?.DisconnectTimestamp != ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: ctx.json?.DisconnectTimestamp != null && ctx.json?.DisconnectTimestamp != ''
if: ctx.json?.DisconnectTimestamp != null && ctx.json.DisconnectTimestamp != ''

"time": "2022-05-26T09:24:00.000Z"
},
"disconnect": {
"time": "1970-01-01T00:00:00.000Z"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an empty value has been used. I can see that it's like that in the event.original, but is that real?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, We got this value in the actual response from Cloudflare itself.

- yyyy-MM-dd'T'HH:mm:ss.SSSZ
- UNIX_MS
timezone: UTC
target_field: cloudflare_logpush.spectrum_event.connect.time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also set event.start from this.

- yyyy-MM-dd'T'HH:mm:ss.SSSZ
- UNIX_MS
timezone: UTC
target_field: cloudflare_logpush.spectrum_event.disconnect.time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set event.end from this?

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

Successfully merging this pull request may close these issues.

Cloudflare Log Push
9 participants