Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add CustomClient option to PushOptions
Problem
When pushing metrics to a VictoriaMetrics Instance that requires mutual TLS authentication with client certificates, the current implementation doesn't allow customizing the HTTP client used for requests. This creates a dilemma:
Solution
Add a
CustomClient
field to thePushOptions
struct that allows specifying a custom HTTP client. This enables users to configure TLS settings specifically for metrics pushing without affecting other parts of the application.Why Not Use vmauth or Traefik?
While vmauth and Traefik are excellent solutions for many scenarios, there are specific use cases where a custom client approach provides significant advantages:
Cross-cloud deployments: When the metrics client is in one cloud provider and the VictoriaMetrics server is in another, setting up an additional proxy layer introduces unnecessary complexity and potential points of failure.
Network complexity: Cross-cloud communications typically traverse public internet, making embedded TLS configuration simpler and more secure than exposing and securing additional proxy services.
Operational simplicity: For many users, configuring the client directly eliminates the need to deploy, manage, and secure additional infrastructure components.
This implementation provides flexibility for users to choose the approach that best fits their specific infrastructure and security requirements.
Use Case
This is particularly useful in multi-cloud environments where metrics need to be pushed between services in different clouds requiring mutual TLS authentication. For example:
Changes
CustomClient *http.Client
field toPushOptions
structnewPushContext
to use the provided client or create a default oneThe implementation maintains backward compatibility with all existing code.
Fixes #88