Skip to content

Commit

Permalink
Adding Insecure Option to bypass tls check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehsan Aliakbar committed Jul 31, 2023
1 parent cf9edf7 commit 3bb6173
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -34,6 +35,7 @@ var opts struct {
Frequency float32 `long:"freq" short:"f" default:"6" help:"Frequency in hours with which to query the Prometheus API."`
ServiceRegex string `long:"regex" short:"r" default:"prometheus-[a-zA-Z0-9_-]+" help:"If any found services don't match the regex, they are ignored."`
LogLevel string `long:"log.level" short:"l" default:"info" help:"Level for logging. Options (in order of verbosity): [debug, info, warn, error, fatal]."`
Insecure bool `long:"insecure" short:"k" help:"Allow insecure Https connections"`
}

func collectMetrics() {
Expand Down Expand Up @@ -210,6 +212,12 @@ func collectMetrics() {

prometheusClient := &http.Client{}

if opts.Insecure {
customTransport := http.DefaultTransport.(*http.Transport).Clone()
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
prometheusClient = &http.Client{Transport: customTransport}
}

fetchingStatusLog := fmt.Sprintf("Fetching current Prometheus status, from Prometheus instance: %v. Sharded instance: %v. Namespace: %v.", instance.InstanceName, instance.ShardedInstanceName, instance.Namespace)
if instance.AuthValue != "" {
fetchingStatusLog += " Including Authorization header."
Expand Down

0 comments on commit 3bb6173

Please sign in to comment.