From db8ccea9daea048e4617a0a308307f9fc909df7b Mon Sep 17 00:00:00 2001 From: Hang Xie <7977860+hangxie@users.noreply.github.com> Date: Tue, 7 Jul 2020 07:20:20 -0700 Subject: [PATCH] Close connection to scrape target after retrieving data (#39) --- Dockerfile | 2 +- prometheus_to_cloudwatch.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f72a989..cdba8d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10.0 as builder +FROM golang:1.13.11 as builder RUN mkdir -p /go/src/github.com/cloudposse/prometheus-to-cloudwatch WORKDIR /go/src/github.com/cloudposse/prometheus-to-cloudwatch COPY . . diff --git a/prometheus_to_cloudwatch.go b/prometheus_to_cloudwatch.go index 6db0e25..2f4bdaf 100644 --- a/prometheus_to_cloudwatch.go +++ b/prometheus_to_cloudwatch.go @@ -514,6 +514,7 @@ func fetchMetricFamilies( } client := &http.Client{Transport: transport} decodeContent(client, url, ch) + client.CloseIdleConnections() } func decodeContent(client *http.Client, url string, ch chan<- *dto.MetricFamily) {