diff --git a/app/core/thanos_client.py b/app/core/thanos_client.py index 812f25e..d00a89b 100644 --- a/app/core/thanos_client.py +++ b/app/core/thanos_client.py @@ -26,12 +26,31 @@ class ThanosClient: self.thanos_url = thanos_url or self._get_thanos_url() self.session = requests.Session() self.session.timeout = 30 + # Disable SSL verification for self-signed certificates + self.session.verify = False + # Disable SSL warnings + import urllib3 + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + + # Add service account token for authentication + self._add_auth_token() def _get_thanos_url(self) -> str: """Get Thanos URL from environment or use default.""" import os return os.getenv('THANOS_URL', 'http://thanos-query:9090') + def _add_auth_token(self): + """Add service account token for authentication.""" + try: + with open('/var/run/secrets/kubernetes.io/serviceaccount/token', 'r') as f: + token = f.read().strip() + self.session.headers.update({ + 'Authorization': f'Bearer {token}' + }) + except FileNotFoundError: + logger.warning("Service account token not found, proceeding without authentication") + def query(self, query: str, time: str = None) -> Dict[str, Any]: """ Execute instant query against Thanos. diff --git a/k8s/configmap.yaml b/k8s/configmap.yaml index 322c8d1..53a0d12 100644 --- a/k8s/configmap.yaml +++ b/k8s/configmap.yaml @@ -24,7 +24,7 @@ data: PROMETHEUS_URL: "https://prometheus-k8s.openshift-monitoring.svc.cluster.local:9091" # URL do Thanos - THANOS_URL: "https://thanos-query.openshift-monitoring.svc.cluster.local:9091" + THANOS_URL: "https://thanos-querier.openshift-monitoring.svc.cluster.local:9091" # Configurações de relatório REPORT_EXPORT_PATH: "/tmp/reports"