vectordotdev / vector

A high-performance observability data pipeline.
https://vector.dev
Mozilla Public License 2.0
17.65k stars 1.56k forks source link

Support http body data validation for http_server source #18045

Open IFtech-A opened 1 year ago

IFtech-A commented 1 year ago

A note for the community

Use Cases

We use vector agents as event receivers from different devices, each developed by separate teams. Adding HTTP body validation ensures data integrity for events. It allows us to respond with a bad request status for events that do not match the receiver's custom data validation.

Attempted Solutions

No response

Proposal

It would be possible, if we add a field for http_server with a VRL source, and execute it after body decoding completes.

References

No response

Version

No response

jszwedko commented 1 year ago

What sorts of validations are you thinking of @IFtech-A ?

IFtech-A commented 1 year ago

Thank you for your response!

Validation of fields’ existence, data type checks, fields’ data type dependent validations(min max values, date format checking, etc.). If validations fail respond with bad request status.

jszwedko commented 1 year ago

Gotcha! As a workaround, you could consider spinning up a separate HTTP server receive the data and do this validation before forwarding the data to Vector. I suggest this because I think it'll be a while before Vector supports something like this natively 🤔

IFtech-A commented 1 year ago

What if I try it and make a pull request? Would that be okay ?

jszwedko commented 1 year ago

What if I try it and make a pull request? Would that be okay ?

I think we'd be open to this as a general concept, but this is the first time we'd be introducing this sort of functionality into Vector and so it would likely involve a decent amount of discussion around what the correct user experience should be. I think the simplest and probably least contentious option would be to add JSON schema validation to the json decoding. Would that satisfy your use case?

IFtech-A commented 1 year ago

That won't be enough for our case, we will put another API for now then. Thank you for help. You may close the issue if you think it won't be helpful.

jszwedko commented 1 year ago

Gotcha, yeah, if JSON schema isn't sufficient, I think we'd need to pursue an RFC proposing another approach since there is likely to be more discussion. I'll mark this as an "idea" and we can see if we get additional use-cases from others.