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
# |
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 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). |
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
# basic pfctl control | |
# == | |
# Related: http://www.OpenBSD.org | |
# Last update: Tue Dec 28, 2004 | |
# == | |
# Note: | |
# this document is only provided as a basic overview | |
# for some common pfctl commands and is by no means | |
# a replacement for the pfctl and pf manual pages. |