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

custom client option #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chou-godaddy
Copy link

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:

  1. Modify the global HTTP DefaultTransport (affecting all HTTP clients in the application)
  2. Create a custom metrics pusher implementation

Solution

Add a CustomClient field to the PushOptions 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:

  1. 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.

  2. Network complexity: Cross-cloud communications typically traverse public internet, making embedded TLS configuration simpler and more secure than exposing and securing additional proxy services.

  3. 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:

  • Pushing metrics from services in one cloud provider to a VictoriaMetrics instance in another cloud
  • Using client certificates for authentication between environments
  • Configuring specific timeouts or connection parameters for metrics pushing

Changes

  • Added CustomClient *http.Client field to PushOptions struct
  • Modified newPushContext to use the provided client or create a default one
  • Added tests to verify the custom client is used correctly with TLS configuration

The implementation maintains backward compatibility with all existing code.

Fixes #88

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

Successfully merging this pull request may close these issues.

Custom httpclient support
1 participant