Skip to content

Instantly share code, notes, and snippets.

View krzysztofantczak's full-sized avatar

Krzysztof Antczak krzysztofantczak

View GitHub Profile
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)
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'
# 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
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
import os
import signal
import socket
import sys
import threading
import time
from prometheus_client import start_http_server, Gauge, Counter
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")
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 = []
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()
@krzysztofantczak
krzysztofantczak / 002.Kafka.PKCS12.SSL
Last active February 2, 2024 07:22
Kafka PKCS12 SSL
#
import numpy as np
import scipy, scipy.signal
def fftconvolve(in1, in2, mode="full"):
"""Convolve two N-dimensional arrays using FFT.
Convolve `in1` and `in2` using the fast Fourier transform method, with
the output size determined by the `mode` argument.
This is generally much faster than `convolve` for large arrays (n > ~500),
but can be slower when only a few output values are needed, and can only
output float arrays (int or object array inputs will be cast to float).