This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, json | |
import re | |
def jq(json_data, path, value=None, remove=False): | |
""" | |
Find JSON nodes matching the given path in jq-like syntax and update them with value. | |
Args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from prometheus_api_client import PrometheusConnect, PrometheusApiClientException | |
import csv | |
import datetime | |
import re | |
def sanitize_filename(filename): | |
# Replace characters not allowed in filenames with underscore | |
return re.sub(r'[^\w\.]', '_', filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from prometheus_api_client import PrometheusConnect | |
from datetime import datetime | |
# Connect to Prometheus | |
prom = PrometheusConnect(url="http://prometheus.example.com:9090/", disable_ssl=True) | |
# Define labels to filter metrics | |
environment = 'production' | |
appcode = 'your_application_code' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HELP deployment_status Status of deployments | |
# TYPE deployment_status gauge | |
deployment_status{deployment="lib",namespace="arc"} 1.0 | |
deployment_status{deployment="studio",namespace="arc"} 1.0 | |
deployment_status{deployment="harmony",namespace="arc"} 1.0 | |
deployment_status{deployment="prose",namespace="arc"} 1.0 | |
deployment_status{deployment="nginx-deployment",namespace="arc"} 1.0 | |
deployment_status{deployment="studio-dashboard",namespace="arc"} 1.0 | |
deployment_status{deployment="melody",namespace="arc"} 1.0 | |
# HELP available_cpu Available CPU in the namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
import pykerberos | |
# Set the path to your custom krb5.conf file | |
custom_krb5_conf_path = '/path/to/your/custom/krb5.conf' | |
# Set the KRB5_CONFIG environment variable to point to your custom krb5.conf file | |
os.environ['KRB5_CONFIG'] = custom_krb5_conf_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import signal | |
import socket | |
import sys | |
import threading | |
import time | |
from prometheus_client import start_http_server, Gauge, Counter | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
def decode_time_string(time_string): | |
# Split the string into its components | |
components = time_string.split('-') | |
# Check if the string has the correct number of components | |
if len(components) != 4: | |
raise ValueError("Input string does not have the correct format") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import re | |
# Read the data from the text file | |
with open("my-services.txt", "r") as file: | |
data = file.readlines() | |
# Initialize lists to store parsed data | |
server_names = [] | |
container_names = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
class PrometheusAnalyzer: | |
def __init__(self, prometheus_url): | |
self.prometheus_url = prometheus_url | |
def query(self, query, duration='5m', interval='1m'): | |
params = {'query': query, 'time': duration, 'step': interval} | |
response = requests.get(self.prometheus_url + '/api/v1/query_range', params=params) | |
data = response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# |
NewerOlder