Browse Source

Remove Incomplete/Broken Thanos Support (#3192)

Signed-off-by: Matt Bolt <mbolt35@gmail.com>
Matt Bolt 11 months ago
parent
commit
272afc5f0c

+ 0 - 43
modules/prometheus-source/pkg/env/promenv.go

@@ -30,11 +30,6 @@ const (
 	InsecureSkipVerifyEnvVar          = "INSECURE_SKIP_VERIFY"
 	KubeRbacProxyEnabledEnvVar        = "KUBE_RBAC_PROXY_ENABLED"
 
-	ThanosEnabledEnvVar      = "THANOS_ENABLED"
-	ThanosQueryUrlEnvVar     = "THANOS_QUERY_URL"
-	ThanosOffsetEnvVar       = "THANOS_QUERY_OFFSET"
-	ThanosMaxSourceResEnvVar = "THANOS_MAX_SOURCE_RESOLUTION"
-
 	DBBasicAuthUsername = "DB_BASIC_AUTH_USERNAME"
 	DBBasicAuthPassword = "DB_BASIC_AUTH_PW"
 	DBBearerToken       = "DB_BEARER_TOKEN"
@@ -123,43 +118,6 @@ func GetETLResolution() time.Duration {
 	return secs * time.Second
 }
 
-// IsThanosEnabled returns the environment variable value for ThanosEnabledEnvVar which represents whether
-// or not thanos is enabled.
-func IsThanosEnabled() bool {
-	return env.GetBool(ThanosEnabledEnvVar, false)
-}
-
-// GetThanosQueryUrl returns the environment variable value for ThanosQueryUrlEnvVar which represents the
-// target query endpoint for hitting thanos.
-func GetThanosQueryUrl() string {
-	return env.Get(ThanosQueryUrlEnvVar, "")
-}
-
-// GetThanosOffset returns the environment variable value for ThanosOffsetEnvVar which represents the total
-// amount of time to offset all queries made to thanos.
-func GetThanosOffset() string {
-	return env.Get(ThanosOffsetEnvVar, "3h")
-}
-
-// GetThanosMaxSourceResolution returns the environment variable value for ThanosMaxSourceResEnvVar which represents
-// the max source resolution to use when querying thanos.
-func GetThanosMaxSourceResolution() string {
-	res := env.Get(ThanosMaxSourceResEnvVar, "raw")
-
-	switch res {
-	case "raw":
-		return "0s"
-	case "0s":
-		fallthrough
-	case "5m":
-		fallthrough
-	case "1h":
-		return res
-	default:
-		return "0s"
-	}
-}
-
 // GetMaxQueryConcurrency returns the environment variable value for MaxQueryConcurrencyEnvVar
 func GetMaxQueryConcurrency() int {
 	maxQueryConcurrency := env.GetInt(MaxQueryConcurrencyEnvVar, 5)
@@ -180,7 +138,6 @@ func GetDBBasicAuthUsername() string {
 
 func GetDBBasicAuthUserPassword() string {
 	return env.Get(DBBasicAuthPassword, "")
-
 }
 
 func GetDBBearerToken() string {

+ 1 - 5
modules/prometheus-source/pkg/prom/clustermap.go

@@ -8,7 +8,6 @@ import (
 	"time"
 
 	"github.com/opencost/opencost/modules/prometheus-source/pkg/env"
-	"github.com/opencost/opencost/modules/prometheus-source/pkg/thanos"
 
 	"github.com/opencost/opencost/core/pkg/clusters"
 	"github.com/opencost/opencost/core/pkg/log"
@@ -30,7 +29,7 @@ type PrometheusClusterMap struct {
 	stop           chan struct{}
 }
 
-// newPrometheusClusterMap creates a new ClusterMap implementation using a prometheus or thanos client
+// newPrometheusClusterMap creates a new ClusterMap implementation using prometheus
 func newPrometheusClusterMap(contextFactory *ContextFactory, cip clusters.ClusterInfoProvider, refresh time.Duration) clusters.ClusterMap {
 	stop := make(chan struct{})
 
@@ -70,9 +69,6 @@ func clusterInfoQuery(offset string) string {
 // loadClusters loads all the cluster info to map
 func (pcm *PrometheusClusterMap) loadClusters() (map[string]*clusters.ClusterInfo, error) {
 	var offset string = ""
-	if IsThanos(pcm.contextFactory.client) {
-		offset = thanos.QueryOffset()
-	}
 
 	// Execute Query
 	tryQuery := func() (interface{}, error) {

+ 0 - 82
modules/prometheus-source/pkg/prom/config.go

@@ -6,7 +6,6 @@ import (
 	"time"
 
 	"github.com/opencost/opencost/core/pkg/log"
-	"github.com/opencost/opencost/core/pkg/util/timeutil"
 	"github.com/opencost/opencost/modules/prometheus-source/pkg/env"
 
 	restclient "k8s.io/client-go/rest"
@@ -34,12 +33,6 @@ type OpenCostPrometheusConfig struct {
 	DataResolutionMinutes int
 }
 
-type OpenCostThanosConfig struct {
-	*OpenCostPrometheusConfig
-
-	MaxSourceResulution string
-}
-
 func (ocpc *OpenCostPrometheusConfig) IsRateLimitRetryEnabled() bool {
 	return ocpc.ClientConfig.RateLimitRetryOpts != nil
 }
@@ -134,78 +127,3 @@ func NewOpenCostPrometheusConfigFromEnv() (*OpenCostPrometheusConfig, error) {
 		DataResolutionMinutes: resolutionMinutes,
 	}, nil
 }
-
-// NewOpenCostPrometheusConfigFromEnv creates a new OpenCostPrometheusConfig from environment variables.
-func NewOpenCostThanosConfigFromEnv() (*OpenCostThanosConfig, error) {
-	serverEndpoint := env.GetThanosQueryUrl()
-	if serverEndpoint == "" {
-		return nil, fmt.Errorf("no address for thanos set in $%s", env.ThanosQueryUrlEnvVar)
-	}
-
-	queryConcurrency := env.GetMaxQueryConcurrency()
-	log.Infof("Thanos Client Max Concurrency set to %d", queryConcurrency)
-
-	timeout := env.GetPrometheusQueryTimeout()
-	keepAlive := env.GetPrometheusKeepAlive()
-	tlsHandshakeTimeout := env.GetPrometheusTLSHandshakeTimeout()
-
-	jobName := env.GetJobName()
-	scrapeInterval := env.GetScrapeInterval()
-
-	maxQueryDuration := env.GetETLMaxPrometheusQueryDuration()
-	clusterLabel := env.GetPromClusterLabel()
-
-	var rateLimitRetryOpts *RateLimitRetryOpts = nil
-	if env.IsPrometheusRetryOnRateLimitResponse() {
-		rateLimitRetryOpts = &RateLimitRetryOpts{
-			MaxRetries:       env.GetPrometheusRetryOnRateLimitMaxRetries(),
-			DefaultRetryWait: env.GetPrometheusRetryOnRateLimitDefaultWait(),
-		}
-	}
-
-	auth := &ClientAuth{
-		Username:    env.GetMultiClusterBasicAuthUsername(),
-		Password:    env.GetMultiClusterBasicAuthPassword(),
-		BearerToken: env.GetMultiClusterBearerToken(),
-	}
-
-	clientConfig := &PrometheusClientConfig{
-		Timeout:               timeout,
-		KeepAlive:             keepAlive,
-		TLSHandshakeTimeout:   tlsHandshakeTimeout,
-		TLSInsecureSkipVerify: env.IsInsecureSkipVerify(),
-		RateLimitRetryOpts:    rateLimitRetryOpts,
-		Auth:                  auth,
-		QueryConcurrency:      queryConcurrency,
-		QueryLogFile:          env.GetQueryLoggingFile(),
-		HeaderXScopeOrgId:     "",
-		RootCAs:               nil,
-	}
-
-	thanosQueryOffset := env.GetThanosOffset()
-	d, err := timeutil.ParseDuration(thanosQueryOffset)
-	if err != nil {
-		return nil, fmt.Errorf("failed to parse thanos query offset: %w", err)
-	}
-
-	dataResolution := env.GetETLResolution()
-
-	return &OpenCostThanosConfig{
-		OpenCostPrometheusConfig: &OpenCostPrometheusConfig{
-			ServerEndpoint:     serverEndpoint,
-			Version:            "0.0.0",
-			IsOffsetResolution: false,
-			ClientConfig:       clientConfig,
-			ScrapeInterval:     scrapeInterval,
-			JobName:            jobName,
-			Offset:             thanosQueryOffset,
-			QueryOffset:        d,
-			MaxQueryDuration:   maxQueryDuration,
-			ClusterID:          "", // thanos is multi-cluster
-			ClusterFilter:      "", // thanos is multi-cluster
-			ClusterLabel:       clusterLabel,
-			DataResolution:     dataResolution,
-		},
-		MaxSourceResulution: env.GetThanosMaxSourceResolution(),
-	}, nil
-}

+ 4 - 164
modules/prometheus-source/pkg/prom/datasource.go

@@ -9,7 +9,6 @@ import (
 
 	"github.com/Masterminds/semver/v3"
 	"github.com/julienschmidt/httprouter"
-	"github.com/opencost/opencost/modules/prometheus-source/pkg/env"
 
 	"github.com/opencost/opencost/core/pkg/clusters"
 	"github.com/opencost/opencost/core/pkg/diagnostics"
@@ -82,10 +81,6 @@ type PrometheusDataSource struct {
 	promClient   prometheus.Client
 	promContexts *ContextFactory
 
-	thanosConfig   *OpenCostThanosConfig
-	thanosClient   prometheus.Client
-	thanosContexts *ContextFactory
-
 	metricsQuerier *PrometheusMetricsQuerier
 	clusterMap     clusters.ClusterMap
 	clusterInfo    clusters.ClusterInfoProvider
@@ -100,20 +95,11 @@ func NewDefaultPrometheusDataSource(clusterInfoProvider clusters.ClusterInfoProv
 		return nil, fmt.Errorf("failed to create prometheus config from env: %w", err)
 	}
 
-	var thanosConfig *OpenCostThanosConfig
-	if env.IsThanosEnabled() {
-		// thanos initialization is not fatal, so we log the error and continue
-		thanosConfig, err = NewOpenCostThanosConfigFromEnv()
-		if err != nil {
-			log.Warnf("Thanos was enabled, but failed to create thanos config from env: %s. Continuing...", err.Error())
-		}
-	}
-
-	return NewPrometheusDataSource(clusterInfoProvider, config, thanosConfig)
+	return NewPrometheusDataSource(clusterInfoProvider, config)
 }
 
 // NewPrometheusDataSource initializes clients for Prometheus and Thanos, and returns a new PrometheusDataSource.
-func NewPrometheusDataSource(infoProvider clusters.ClusterInfoProvider, promConfig *OpenCostPrometheusConfig, thanosConfig *OpenCostThanosConfig) (*PrometheusDataSource, error) {
+func NewPrometheusDataSource(infoProvider clusters.ClusterInfoProvider, promConfig *OpenCostPrometheusConfig) (*PrometheusDataSource, error) {
 	promClient, err := NewPrometheusClient(promConfig.ServerEndpoint, promConfig.ClientConfig)
 	if err != nil {
 		return nil, fmt.Errorf("failed to build prometheus client: %w", err)
@@ -167,68 +153,26 @@ func NewPrometheusDataSource(infoProvider clusters.ClusterInfoProvider, promConf
 
 	promContexts := NewContextFactory(promClient, promConfig)
 
-	var thanosClient prometheus.Client
-	var thanosContexts *ContextFactory
-
-	// if the thanos configuration is non-nil, we assume intent to use thanos. However, failure to
-	// initialize the thanos client is not fatal, and we will log the error and continue.
-	if thanosConfig != nil {
-		thanosHost := thanosConfig.ServerEndpoint
-		if thanosHost != "" {
-			thanosCli, _ := NewThanosClient(thanosHost, thanosConfig)
-
-			_, err = Validate(thanosCli, thanosConfig.OpenCostPrometheusConfig)
-			if err != nil {
-				log.Warnf("Failed to query Thanos at %s. Error: %s.", thanosHost, err.Error())
-				thanosClient = thanosCli
-			} else {
-				log.Infof("Success: retrieved the 'up' query against Thanos at: %s", thanosHost)
-
-				thanosClient = thanosCli
-			}
-
-			thanosContexts = NewContextFactory(thanosClient, thanosConfig.OpenCostPrometheusConfig)
-		} else {
-			log.Infof("Error resolving environment variable: $%s", env.ThanosQueryUrlEnvVar)
-		}
-	}
-
 	// metadata creation for cluster info
-	thanosEnabled := thanosClient != nil
 	metadata := map[string]string{
-		clusters.ClusterInfoThanosEnabledKey: fmt.Sprintf("%t", thanosEnabled),
-	}
-	if thanosEnabled {
-		metadata[clusters.ClusterInfoThanosOffsetKey] = thanosConfig.Offset
+		clusters.ClusterInfoThanosEnabledKey: "false",
 	}
 
 	// cluster info provider
 	clusterInfoProvider := clusters.NewClusterInfoDecorator(infoProvider, metadata)
-
-	var clusterMap clusters.ClusterMap
-	if thanosEnabled {
-		clusterMap = newPrometheusClusterMap(thanosContexts, clusterInfoProvider, 10*time.Minute)
-	} else {
-		clusterMap = newPrometheusClusterMap(promContexts, clusterInfoProvider, 5*time.Minute)
-	}
+	clusterMap := newPrometheusClusterMap(promContexts, clusterInfoProvider, 5*time.Minute)
 
 	// create metrics querier implementation for prometheus and thanos
 	metricsQuerier := newPrometheusMetricsQuerier(
 		promConfig,
 		promClient,
 		promContexts,
-		thanosConfig,
-		thanosClient,
-		thanosContexts,
 	)
 
 	return &PrometheusDataSource{
 		promConfig:     promConfig,
 		promClient:     promClient,
 		promContexts:   promContexts,
-		thanosConfig:   thanosConfig,
-		thanosClient:   thanosClient,
-		thanosContexts: thanosContexts,
 		metricsQuerier: metricsQuerier,
 		clusterMap:     clusterMap,
 		clusterInfo:    clusterInfoProvider,
@@ -388,82 +332,6 @@ func (pds *PrometheusDataSource) prometheusQueryRange(w http.ResponseWriter, r *
 	w.Write(body)
 }
 
-// thanosQuery is a proxy for /query against thanos
-func (pds *PrometheusDataSource) thanosQuery(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
-	w.Header().Set("Content-Type", "application/json")
-	w.Header().Set("Access-Control-Allow-Origin", "*")
-
-	if pds.thanosClient == nil {
-		proto.WriteResponse(w, proto.ToResponse(nil, fmt.Errorf("ThanosDisabled")))
-		return
-	}
-
-	qp := httputil.NewQueryParams(r.URL.Query())
-	query := qp.Get("query", "")
-	if query == "" {
-		proto.WriteResponse(w, proto.ToResponse(nil, fmt.Errorf("Query Parameter 'query' is unset'")))
-		return
-	}
-
-	// Attempt to parse time as either a unix timestamp or as an RFC3339 value
-	var timeVal time.Time
-	timeStr := qp.Get("time", "")
-	if len(timeStr) > 0 {
-		if t, err := strconv.ParseInt(timeStr, 10, 64); err == nil {
-			timeVal = time.Unix(t, 0)
-		} else if t, err := time.Parse(time.RFC3339, timeStr); err == nil {
-			timeVal = t
-		}
-
-		// If time is given, but not parse-able, return an error
-		if timeVal.IsZero() {
-			http.Error(w, fmt.Sprintf("time must be a unix timestamp or RFC3339 value; illegal value given: %s", timeStr), http.StatusBadRequest)
-		}
-	}
-
-	ctx := pds.thanosContexts.NewNamedContext(FrontendContextName)
-	body, err := ctx.RawQuery(query, timeVal)
-	if err != nil {
-		proto.WriteResponse(w, proto.ToResponse(nil, fmt.Errorf("Error running query %s. Error: %s", query, err)))
-		return
-	}
-
-	w.Write(body)
-}
-
-// thanosQueryRange is a proxy for /query_range against thanos
-func (pds *PrometheusDataSource) thanosQueryRange(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
-	w.Header().Set("Content-Type", "application/json")
-	w.Header().Set("Access-Control-Allow-Origin", "*")
-
-	if pds.thanosClient == nil {
-		proto.WriteResponse(w, proto.ToResponse(nil, fmt.Errorf("ThanosDisabled")))
-		return
-	}
-
-	qp := httputil.NewQueryParams(r.URL.Query())
-	query := qp.Get("query", "")
-	if query == "" {
-		fmt.Fprintf(w, "Error parsing query from request parameters.")
-		return
-	}
-
-	start, end, duration, err := toStartEndStep(qp)
-	if err != nil {
-		fmt.Fprintf(w, "error: %s", err)
-		return
-	}
-
-	ctx := pds.thanosContexts.NewNamedContext(FrontendContextName)
-	body, err := ctx.RawQueryRange(query, start, end, duration)
-	if err != nil {
-		fmt.Fprintf(w, "Error running query %s. Error: %s", query, err)
-		return
-	}
-
-	w.Write(body)
-}
-
 // promtheusQueueState returns the current state of the prometheus and thanos request queues
 func (pds *PrometheusDataSource) prometheusQueueState(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
 	w.Header().Set("Content-Type", "application/json")
@@ -479,15 +347,6 @@ func (pds *PrometheusDataSource) prometheusQueueState(w http.ResponseWriter, _ *
 		"prometheus": promQueueState,
 	}
 
-	if pds.thanosClient != nil {
-		thanosQueueState, err := GetPrometheusQueueState(pds.thanosClient, pds.thanosConfig.OpenCostPrometheusConfig)
-		if err != nil {
-			log.Warnf("Error getting Thanos queue state: %s", err)
-		} else {
-			result["thanos"] = thanosQueueState
-		}
-	}
-
 	proto.WriteResponse(w, proto.ToResponse(result, nil))
 }
 
@@ -502,11 +361,6 @@ func (pds *PrometheusDataSource) prometheusMetrics(w http.ResponseWriter, _ *htt
 		"prometheus": promMetrics,
 	}
 
-	if pds.thanosClient != nil {
-		thanosMetrics := GetPrometheusMetrics(pds.thanosClient, pds.thanosConfig.OpenCostPrometheusConfig, pds.thanosConfig.Offset)
-		result["thanos"] = thanosMetrics
-	}
-
 	proto.WriteResponse(w, proto.ToResponse(result, nil))
 }
 
@@ -522,18 +376,6 @@ func (pds *PrometheusDataSource) PrometheusContexts() *ContextFactory {
 	return pds.promContexts
 }
 
-func (pds *PrometheusDataSource) ThanosClient() prometheus.Client {
-	return pds.thanosClient
-}
-
-func (pds *PrometheusDataSource) ThanosConfig() *OpenCostThanosConfig {
-	return pds.thanosConfig
-}
-
-func (pds *PrometheusDataSource) ThanosContexts() *ContextFactory {
-	return pds.thanosContexts
-}
-
 func (pds *PrometheusDataSource) RegisterEndPoints(router *httprouter.Router) {
 	// endpoints migrated from server
 	router.GET("/validatePrometheus", pds.prometheusMetadata)
@@ -545,8 +387,6 @@ func (pds *PrometheusDataSource) RegisterEndPoints(router *httprouter.Router) {
 	// prom query proxies
 	router.GET("/prometheusQuery", pds.prometheusQuery)
 	router.GET("/prometheusQueryRange", pds.prometheusQueryRange)
-	router.GET("/thanosQuery", pds.thanosQuery)
-	router.GET("/thanosQueryRange", pds.thanosQueryRange)
 
 	// diagnostics
 	router.GET("/diagnostics/requestQueue", pds.prometheusQueueState)

+ 0 - 10
modules/prometheus-source/pkg/prom/ids.go

@@ -11,11 +11,6 @@ const (
 	// targets prometheus. This can be used to check a specific client instance
 	// by calling prom.IsClientID(client, prom.PrometheusClientID)
 	PrometheusClientID string = "Prometheus"
-
-	// ThanosClientID is the identifier used when creating the client that
-	// targets thanos. This can be used to check a specific client instance
-	// by calling prom.IsClientID(client, prom.ThanosClientID)
-	ThanosClientID string = "Thanos"
 )
 
 // identityClient provides an interface for extracting an indentifer from the client objects
@@ -40,8 +35,3 @@ func IsClientID(cli prometheus.Client, id string) bool {
 func IsPrometheus(cli prometheus.Client) bool {
 	return IsClientID(cli, PrometheusClientID)
 }
-
-// IsThanos returns true if the client provided is used to target thanos
-func IsThanos(cli prometheus.Client) bool {
-	return IsClientID(cli, ThanosClientID)
-}

+ 3 - 13
modules/prometheus-source/pkg/prom/metricsquerier.go

@@ -18,27 +18,17 @@ type PrometheusMetricsQuerier struct {
 	promConfig   *OpenCostPrometheusConfig
 	promClient   prometheus.Client
 	promContexts *ContextFactory
-
-	thanosConfig   *OpenCostThanosConfig
-	thanosClient   prometheus.Client
-	thanosContexts *ContextFactory
 }
 
 func newPrometheusMetricsQuerier(
 	promConfig *OpenCostPrometheusConfig,
 	promClient prometheus.Client,
 	promContexts *ContextFactory,
-	thanosConfig *OpenCostThanosConfig,
-	thanosClient prometheus.Client,
-	thanosContexts *ContextFactory,
 ) *PrometheusMetricsQuerier {
 	return &PrometheusMetricsQuerier{
-		promConfig:     promConfig,
-		promClient:     promClient,
-		promContexts:   promContexts,
-		thanosConfig:   thanosConfig,
-		thanosClient:   thanosClient,
-		thanosContexts: thanosContexts,
+		promConfig:   promConfig,
+		promClient:   promClient,
+		promContexts: promContexts,
 	}
 }
 

+ 12 - 6
modules/prometheus-source/pkg/prom/prom.go

@@ -45,6 +45,15 @@ type ClientAuth struct {
 	BearerToken string
 }
 
+// DefaultClientAuth returns a non-nil default ClientAuth instance.
+func DefaultClientAuth() *ClientAuth {
+	return &ClientAuth{
+		Username:    "",
+		Password:    "",
+		BearerToken: "",
+	}
+}
+
 // Apply Applies the authentication data to the request headers
 func (auth *ClientAuth) Apply(req *http.Request) {
 	if auth == nil {
@@ -139,7 +148,8 @@ func NewRateLimitedClient(
 	decorator QueryParamsDecorator,
 	rateLimitRetryOpts *RateLimitRetryOpts,
 	queryLogFile string,
-	headerXScopeOrgId string) (prometheus.Client, error) {
+	headerXScopeOrgId string,
+) (prometheus.Client, error) {
 
 	queue := collections.NewBlockingQueue[*workRequest]()
 
@@ -166,11 +176,7 @@ func NewRateLimitedClient(
 
 	// default authentication
 	if auth == nil {
-		auth = &ClientAuth{
-			Username:    "",
-			Password:    "",
-			BearerToken: "",
-		}
+		auth = DefaultClientAuth()
 	}
 
 	rlpc := &RateLimitedPrometheusClient{

+ 0 - 60
modules/prometheus-source/pkg/prom/thanos.go

@@ -1,60 +0,0 @@
-package prom
-
-import (
-	"crypto/tls"
-	"net"
-	"net/http"
-	"net/url"
-	"strings"
-
-	prometheus "github.com/prometheus/client_golang/api"
-)
-
-// MaxSourceResulution is the query parameter key used to designate the resolution
-// to use when executing a query.
-const MaxSourceResulution = "max_source_resolution"
-
-// NewThanosClient creates a new `prometheus.Client` with the specific thanos configuration, with a
-// thanos client identifier.
-func NewThanosClient(address string, thanosConfig *OpenCostThanosConfig) (prometheus.Client, error) {
-	config := thanosConfig.ClientConfig
-
-	tc := prometheus.Config{
-		Address: address,
-		RoundTripper: &http.Transport{
-			Proxy: http.ProxyFromEnvironment,
-			DialContext: (&net.Dialer{
-				Timeout:   config.Timeout,
-				KeepAlive: config.KeepAlive,
-			}).DialContext,
-			TLSHandshakeTimeout: config.TLSHandshakeTimeout,
-			TLSClientConfig: &tls.Config{
-				InsecureSkipVerify: config.TLSInsecureSkipVerify,
-			},
-		},
-	}
-
-	client, err := prometheus.NewClient(tc)
-	if err != nil {
-		return nil, err
-	}
-
-	// max source resolution decorator
-	maxSourceDecorator := func(path string, queryParams url.Values) url.Values {
-		if strings.Contains(path, "query") {
-			queryParams.Set(MaxSourceResulution, thanosConfig.MaxSourceResulution)
-		}
-		return queryParams
-	}
-
-	return NewRateLimitedClient(
-		ThanosClientID,
-		client,
-		config.QueryConcurrency,
-		config.Auth,
-		maxSourceDecorator,
-		config.RateLimitRetryOpts,
-		config.QueryLogFile,
-		"",
-	)
-}

+ 1 - 5
modules/prometheus-source/pkg/prom/validate.go

@@ -8,7 +8,7 @@ import (
 
 const UpQuery = "up"
 
-// PrometheusMetadata represents a validation result for prometheus/thanos running
+// PrometheusMetadata represents a validation result for prometheus running
 // opencost.
 type PrometheusMetadata struct {
 	Running            bool `json:"running"`
@@ -17,10 +17,6 @@ type PrometheusMetadata struct {
 
 // Validate tells the model what data prometheus has on it.
 func Validate(cli prometheus.Client, config *OpenCostPrometheusConfig) (*PrometheusMetadata, error) {
-	if IsThanos(cli) {
-		return validate(cli, validationQueryFor(config), config)
-	}
-
 	return validate(cli, validationQueryFor(config), config)
 }
 

+ 0 - 56
modules/prometheus-source/pkg/thanos/thanos.go

@@ -1,56 +0,0 @@
-package thanos
-
-import (
-	"fmt"
-	"sync"
-	"time"
-
-	"github.com/opencost/opencost/modules/prometheus-source/pkg/env"
-)
-
-var (
-	lock           = new(sync.Mutex)
-	enabled        = env.IsThanosEnabled()
-	queryUrl       = env.GetThanosQueryUrl()
-	offset         = env.GetThanosOffset()
-	maxSourceRes   = env.GetThanosMaxSourceResolution()
-	offsetDuration *time.Duration
-	queryOffset    = fmt.Sprintf(" offset %s", offset)
-)
-
-// IsEnabled returns true if Thanos is enabled.
-func IsEnabled() bool {
-	return enabled
-}
-
-// QueryURL returns true if Thanos is enabled.
-func QueryURL() string {
-	return queryUrl
-}
-
-// Offset returns the duration string for the query offset that should be applied to thanos
-func Offset() string {
-	return offset
-}
-
-// OffsetDuration returns the Offset as a parsed duration
-func OffsetDuration() time.Duration {
-	lock.Lock()
-	defer lock.Unlock()
-
-	if offsetDuration == nil {
-		d, err := time.ParseDuration(offset)
-		if err != nil {
-			d = 0
-		}
-
-		offsetDuration = &d
-	}
-
-	return *offsetDuration
-}
-
-// QueryOffset returns a string in the format: " offset %s" substituting in the Offset() string.
-func QueryOffset() string {
-	return queryOffset
-}