Skip to content

Commit

Permalink
Add auth parameter to enable Custom HTTP authentication like AWS Sigv4
Browse files Browse the repository at this point in the history
  • Loading branch information
angelotessaro committed Feb 18, 2024
1 parent 2518a4a commit 0691243
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class PrometheusRemoteWriteMetricsExporter(MetricExporter):
timeout: timeout for remote write requests in seconds, defaults to 30 (Optional)
proxies: dict mapping request proxy protocols to proxy urls (Optional)
tls_config: configuration for remote write TLS settings (Optional)
auth: auth tuple or callable to enable Basic/Digest/Custom HTTP Auth (Optional)
"""

def __init__(
Expand All @@ -79,6 +80,7 @@ def __init__(
resources_as_labels: bool = True,
preferred_temporality: Dict[type, AggregationTemporality] = None,
preferred_aggregation: Dict = None,
auth = None,
):
self.endpoint = endpoint
self.basic_auth = basic_auth
Expand All @@ -87,6 +89,7 @@ def __init__(
self.tls_config = tls_config
self.proxies = proxies
self.resources_as_labels = resources_as_labels
self.auth = auth

if not preferred_temporality:
preferred_temporality = {
Expand Down Expand Up @@ -181,6 +184,14 @@ def headers(self):
def headers(self, headers: Dict):
self._headers = headers

@property
def auth(self):
return self._auth

@auth.setter
def auth(self, auth):
self._auth = auth

def export(
self,
metrics_data: MetricsData,
Expand Down Expand Up @@ -370,6 +381,8 @@ def _send_message(
auth = None
if self.basic_auth:
auth = (self.basic_auth["username"], self.basic_auth["password"])
elif self.auth:
auth = self.auth

cert = None
verify = True
Expand Down

0 comments on commit 0691243

Please sign in to comment.