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

feat(new sink): New Relic sink for Events, Metrics and Logs #9764

Merged
merged 64 commits into from
Jan 13, 2022
Merged

feat(new sink): New Relic sink for Events, Metrics and Logs #9764

merged 64 commits into from
Jan 13, 2022

Conversation

asllop
Copy link
Contributor

@asllop asllop commented Oct 22, 2021

Description

A sink for the main New Relic APIs: Events, Metrics, and Logs. The specific API used is specified in the config TOML. This PR includes the sink code, tests, and documentation.

Features

  • Support for New Relic Event, Metric, and Log API.
  • Accept both Vector Event flavors: Metric and LogEvent, and convert them into New Relic API models.
  • Event buffering and push samples in bulk (using New Relic APIs format for grouping samples).
  • In the case of NR Event API, if LogEvent "message" field contains a JSON, it's mapped into NR Event attributes.
  • Optional compression.
  • EU and US endpoints.

Deprecation

  • This sink overlaps with the existing new_relic_log sink, but it surpasses its functionalities: it adds support for NR Events and Metrics, and uses recommended JSON format for grouping samples supported by NR APIs. Also applies some integrity rules to events.

@asllop
Copy link
Contributor Author

asllop commented Dec 2, 2021

All changes suggested by the reviewer have been applied (except NewRelicSinkError, see the conversation for details).


Ok((
super::VectorSink::Stream(Box::new(sink)),
future::ok(()).boxed(),
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a healthcheck? You can look at the existing new relic sink for an example. This is useful to check that the config is correct, and Vector can talk to the API.

Copy link
Contributor Author

@asllop asllop Dec 3, 2021

Choose a reason for hiding this comment

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

Regarding health checks, the New Relic APIs don't document a way to check the status using the API itself (they have a status page, but not something you could request with an API), there is no documented GET, HEAD, or any other method besides the POST used to send the actual data. Although using the POST method with an empty object to check the availability is probably possible, is highly discouraged, because it could contribute to reach the API request limits, degrading the service performance.

https://docs.newrelic.com/docs/data-apis/ingest-apis/introduction-event-api/
https://docs.newrelic.com/docs/data-apis/ingest-apis/metric-api/introduction-metric-api/
https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/

EDITED: Check #9764 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

The healthcheck is only ran a single time when Vector starts up, so I wouldn't worry about API request limits. (And at least for the Events API, you can send 100000 / minute), so if that is your only concern I'd suggest still adding some kind of health check.

The current new_relic_logs sends an empty HEAD request and checks the status code response, but if an empty POST also works, that could be reasonable too.

Copy link
Contributor Author

@asllop asllop Dec 7, 2021

Choose a reason for hiding this comment

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

Sounds fair. Only one question, what if the health check fails? As you said the new_relic_log sink uses a HEAD call, but this method is not documented in the official New Relic API descriptions, so, one would expect that this could suddenly change or even disappear. What would happen in such a case? The sink would continue working or Vector will prevent it from running?

Copy link
Member

Choose a reason for hiding this comment

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

If the healthcheck fails that specific sink won't run. However, if something breaks the healthcheck it can easily be disabled (eg: https://vector.dev/docs/reference/configuration/sinks/new_relic_logs/#healthcheck.enabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented a healthcheck in 9c8e7b2

First of all, I want to apologize for a misleading statement I made. I said that New Relic doesn't provide a status API, and that's not true, they actually does. So I used this API to check the availability of the corresponding New Relic API endpoints.

Copy link
Member

Choose a reason for hiding this comment

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

I think there is a bit of misunderstanding here on the purpose of the healthcheck. This is something that is ran once when Vector starts and is mostly there to verify that the configuration of Vector is correct and it's able to talk to the service. So it should be able to detect issues such as invalid credentials, or invalid network configuration (can't reach the endpoint). Checking the status endpoint does verify part of this, but leaves out checking the credentials. Ideally this would check an endpoint that is actually used by the sink (such as sending an empty POST to upload events, if that is a valid request) so that it is testing everything.
We are working on updating the component spec documentation to further clarify the health checks to make this more clear in the future.

Copy link
Member

Choose a reason for hiding this comment

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

src/sinks/new_relic/service.rs Outdated Show resolved Hide resolved
src/sinks/new_relic/encoding.rs Outdated Show resolved Hide resolved
src/sinks/new_relic/encoding.rs Outdated Show resolved Hide resolved
@asllop
Copy link
Contributor Author

asllop commented Dec 3, 2021

Most of the requested changes are ready. See open conversations for details.

@binarylogic binarylogic requested a review from fuchsnj December 3, 2021 18:03
Copy link
Member

@fuchsnj fuchsnj left a comment

Choose a reason for hiding this comment

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

Overall I think this is pretty close now. Just 2 small comments, and a few small things causing the build to fail.

If you see a way to reasonably add them, integration tests would be nice, but are not a hard requirement.

src/sinks/new_relic/sink.rs Show resolved Hide resolved

Ok((
super::VectorSink::Stream(Box::new(sink)),
future::ok(()).boxed(),
Copy link
Member

Choose a reason for hiding this comment

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

The healthcheck is only ran a single time when Vector starts up, so I wouldn't worry about API request limits. (And at least for the Events API, you can send 100000 / minute), so if that is your only concern I'd suggest still adding some kind of health check.

The current new_relic_logs sends an empty HEAD request and checks the status code response, but if an empty POST also works, that could be reasonable too.

@asllop asllop requested a review from fuchsnj December 12, 2021 07:53
jszwedko added a commit that referenced this pull request Dec 13, 2021
This prompted by some [discussion on the New Relic
sink](#9764 (comment))

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
jszwedko added a commit that referenced this pull request Dec 14, 2021
…10431)

* docs(internal docs): Add note about health checks to component spec

This prompted by some [discussion on the New Relic
sink](#9764 (comment))

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
@fuchsnj
Copy link
Member

fuchsnj commented Jan 5, 2022

@asllop Have you had a chance to take a look at the health check changes from this comment? Updating the healthcheck is the only thing left then I'd be ok to merge this.

@asllop
Copy link
Contributor Author

asllop commented Jan 10, 2022

@asllop Have you had a chance to take a look at the health check changes from this comment? Updating the healthcheck is the only thing left then I'd be ok to merge this.

Done!

@fuchsnj fuchsnj enabled auto-merge (squash) January 13, 2022 15:24
@fuchsnj fuchsnj merged commit 2c02b47 into vectordotdev:master Jan 13, 2022
@fuchsnj
Copy link
Member

fuchsnj commented Jan 13, 2022

Thanks @asllop for your contribution!

@lukasmrtvy
Copy link

@asllop hey, can You take a look at #13377, please? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants