Skip to content

Instantly share code, notes, and snippets.

@octavioranieri
octavioranieri / generate_load.py
Created February 14, 2024 18:07
The code below creates artificial resource usage, useful for reproducing threshold alerts
import time
import math
import multiprocessing
from argparse import ArgumentParser
def generate_cpu_load(interval, utilization):
"Generate a utilization % for a duration of interval seconds"
start_time = time.time()
for i in range(0, int(interval)):
while time.time() - start_time < utilization / 100.0:
@octavioranieri
octavioranieri / docker-compose.yml
Created October 13, 2023 18:47
Example with 3 Kibana instances with LB
---
version: '3'
services:
elasticsearch:
container_name: es01
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
environment: ['ES_JAVA_OPTS=-Xms2g -Xmx2g','bootstrap.memory_lock=true','discovery.type=single-node','xpack.security.enabled=false', 'xpack.security.enrollment.enabled=false']
ports:
- 9200:9200
networks:
@octavioranieri
octavioranieri / change_logging_agents.sh
Last active March 11, 2024 21:49
it updates the logging level for all the online agents
#!/bin/bash
# Replace the values below for your deployment/cluster
KIBANA_ENDPOINT=https://lab.kb.us-east1.gcp.elastic-cloud.com:9243
KIBANA_USER=octavio
KIBANA_PW=super_secret
echo "Collecting the list from online agents..."
#!/bin/bash
SCRIPT_VERSION=v1.0.0
: "${DATE_FORMAT:="%Y-%m-%d %H:%I:%S,%3N"}"
echo "[$(date +"$DATE_FORMAT")][INFO] VERSION: $SCRIPT_VERSION"
# This script performs taks according to a provided command. The supported command values are:
# - generate-certs - Will create temporary ZK stunnel certs if the existing ca-file is found to be expired
# - validate-zk - Will verify ZK quorum after certs have been re-generated and distributed to all directors
@octavioranieri
octavioranieri / disable-adminconsole-indexer.sh
Created October 19, 2022 15:40
ECE found-shell script to disable indexer mode and migrations for the adminconsole container. Create this file, chmod +X it, run it with the bypass option (1), fix your env, run the script again with the cleanup option (2)
#!/bin/bash
set -e
echo "=================================================================================================="
echo "NOTE: The script will set the Adminconsole to api-only mode (no indexer), so that"
echo " migrations are bypassed and Adminconsole can boot for environment salvage operations."
echo " Please run the same script with the cleanup option afterwards."
echo ""
echo "IMPORTANT: Until the cleanup script is run, adminconsole will not be able to index "
echo " changes in the admin cluster, breaking the Deployments dashboard and "