### Start vLLM Server Source: https://openobserve.ai/docs/integration/ai/providers/vllm.md Install vLLM and start a local server with a chosen model. Ensure the server is accessible. ```shell pip install vllm vllm serve facebook/opt-125m --port 8001 ``` -------------------------------- ### Install Dependencies for Bundled Example Source: https://openobserve.ai/docs/integration/ai/llm-applications.md Install necessary Python packages including the OpenObserve SDK, OpenAI, and instrumentation libraries. ```shell uv pip install openobserve-telemetry-sdk openai opentelemetry-instrumentation-openai python-dotenv uv pip install -r requirements.txt ``` -------------------------------- ### Create Namespace and Install OpenObserve Source: https://openobserve.ai/docs/enterprise-setup/azure-aks.md Use these commands to create a namespace and install OpenObserve using Helm. Ensure you have a `values.yaml` file configured for your enterprise setup. ```bash kubectl create namespace $NAMESPACE helm install openobserve openobserve/openobserve -n $NAMESPACE -f values.yaml ``` -------------------------------- ### Basic Installation Source: https://openobserve.ai/docs/administration/configuration/o2-k8s-operator/deploy-script.md Execute the deploy.sh script without any options for a standard installation. ```bash ./deploy.sh ``` -------------------------------- ### Run Bundled OpenAI Example Source: https://openobserve.ai/docs/integration/ai/llm-applications.md Execute the example script to send LLM traces to OpenObserve. ```shell uv run examples/openai_example.py ``` -------------------------------- ### Calling MCP Server Tools Source: https://openobserve.ai/docs/integration/ai/mcp.md This example demonstrates how to call the `tools/call` method on the MCP server to execute a tool, such as `SearchSQL`, with specified arguments. It includes setting up dynamic start and end times for queries. ```APIDOC ## POST /api/default/mcp ### Description This endpoint allows direct interaction with the MCP server to invoke tools for agentic workflows. It uses the JSON-RPC 2.0 protocol. ### Method POST ### Endpoint `/api/{org_id}/mcp` ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC protocol version, should be "2.0". - **method** (string) - Required - The name of the tool or method to call, e.g., "tools/call". - **params** (object) - Required - Parameters for the method call. - **name** (string) - Required - The name of the tool to execute (e.g., "SearchSQL"). - **arguments** (object) - Required - Arguments for the specified tool. - **org_id** (string) - Required - The organization ID. - **request_body** (object) - Required - The specific arguments for the tool's operation. - **query** (object) - Required - Query parameters for `SearchSQL`. - **sql** (string) - Required - The SQL query to execute. - **start_time** (integer) - Required - Epoch microseconds for the start of the time range. - **end_time** (integer) - Required - Epoch microseconds for the end of the time range. - **from** (integer) - Optional - The starting offset for results. - **size** (integer) - Optional - The maximum number of results to return. - **id** (integer) - Required - A unique identifier for the request. ### Request Example ```bash START=$(python3 -c "import time; print(int((time.time() - 3600) * 1_000_000))") END=$(python3 -c "import time; print(int(time.time() * 1_000_000))") curl https://your-instance/api/default/mcp \ -H "Content-Type: application/json" \ -H "Authorization: Basic " \ -d @- < OPENWEBUI_BASE_URL=http://localhost:3001 OPENWEBUI_API_KEY=your-openwebui-api-key OPENWEBUI_MODEL=gpt-4o-mini ``` -------------------------------- ### Verify CloudNativePG Installation Source: https://openobserve.ai/docs/enterprise-setup/azure-aks.md Checks if the CloudNativePG controller manager pod is running in the `cnpg-system` namespace. Allow a short delay for the pod to start. ```bash kubectl get pods -n cnpg-system ``` -------------------------------- ### Example Resource Creation Queries Source: https://openobserve.ai/docs/enterprise-setup/sre-agent.md Sample natural language queries for creating resources like dashboards and alerts using the AI Assistant in OpenObserve. ```text Create a dashboard for monitoring the payment service Set up an alert for when error rate exceeds 5% ``` -------------------------------- ### Get Latest Traces Request Source: https://openobserve.ai/docs/reference/api/traces/trace-search-api.md Example cURL request to retrieve the latest traces within a specified time range and with optional filtering. ```bash curl -X GET \ "https://your-openobserve-instance/api/org_id/stream_name/traces/latest?&filter=&start_time=1751443100969000&end_time=1751444000969000&from=0&size=25 \ -H "Authorization: Basic " ``` -------------------------------- ### Run Python Application Source: https://openobserve.ai/docs/ingestion/traces/python.md Start the Python application server after setting up credentials and configuration. Navigate to the specified URL to generate traces. ```bash python3 app.py ``` -------------------------------- ### Expected Output for Pod Status Verification Source: https://openobserve.ai/docs/enterprise-setup/google-gke.md This shows the expected output for `kubectl get pods` after OpenObserve has started, indicating all components are running. ```text NAME READY STATUS RESTARTS AGE oo-nats-0 2/2 Running 0 2m oo-nats-1 2/2 Running 0 2m oo-nats-2 2/2 Running 0 2m oo-nats-box-... 1/1 Running 0 2m oo-openobserve-alertmanager-0 1/1 Running 0 2m oo-openobserve-compactor-... 1/1 Running 0 2m oo-openobserve-dex-... 1/1 Running 0 2m oo-openobserve-ingester-0 1/1 Running 0 2m oo-openobserve-openfga-... 1/1 Running 0 2m oo-openobserve-postgres-1 1/1 Running 0 2m oo-openobserve-postgres-2 1/1 Running 0 1m oo-openobserve-querier-0 1/1 Running 0 2m oo-openobserve-router-... 1/1 Running 1 2m ``` -------------------------------- ### Get Azure AKS Credentials Source: https://openobserve.ai/docs/enterprise-setup/azure-aks.md Retrieves credentials for your Azure AKS cluster to enable kubectl access. Ensure you have the Azure CLI installed and are logged in. ```bash az aks get-credentials \ --resource-group $RESOURCE_GROUP \ --name $CLUSTER_NAME \ --overwrite-existing ``` -------------------------------- ### Install Dependencies for Direct Integration Source: https://openobserve.ai/docs/integration/ai/llm-applications.md Install the OpenObserve SDK and necessary instrumentation for direct project integration. ```shell uv pip install openobserve-telemetry-sdk opentelemetry-instrumentation-openai dotenv ``` -------------------------------- ### Heroku Log Forwarder Setup Source: https://openobserve.ai/docs/integration/cloud/heroku.md Initializes a new Node.js project for the log forwarder, installs necessary dependencies like express, body-parser, and node-fetch. ```bash mkdir heroku-log-forwarder cd heroku-log-forwarder npm init -y npm install express body-parser node-fetch@2 ``` -------------------------------- ### Configure Environment Variables Source: https://openobserve.ai/docs/integration/ai/providers/cometapi.md Set up a .env file with your OpenObserve credentials and CometAPI key. Ensure the OPENOBSERVE_URL points to your OpenObserve instance. ```shell OPENOBSERVE_URL=http://localhost:5080/ OPENOBSERVE_ORG=default OPENOBSERVE_AUTH_TOKEN=Basic COMETAPI_API_KEY=your-cometapi-api-key ``` -------------------------------- ### Deploy Sample Resources Source: https://openobserve.ai/docs/administration/configuration/o2-k8s-operator/o2-operator-overview.md Deploy sample resources using templates from the `samples/` directory. These include alerts, pipelines, and functions. Note that sample files may reference different `configRef` names. ```bash # Deploy a minimal alert kubectl apply -f samples/alerts/alert9-minimal.template.yaml # Deploy a simple pipeline kubectl apply -f samples/pipelines/srctodest.yaml # Deploy a basic function kubectl apply -f samples/functions/basic-function.yaml ``` -------------------------------- ### Get Latest Traces Response Source: https://openobserve.ai/docs/reference/api/traces/trace-search-api.md Example JSON response format for the latest traces endpoint, showing total traces, trace ID, and a list of trace hits. ```json { "total": 1, "trace_id": "b1eeb579ae863bdf9408e7d64c02d5d1", "hits": [ { "duration": 9, "end_time": 1751444644327767600, "first_event": { "_timestamp": 1751444644327758, "duration": 9, "end_time": 1751444644327767600, "operation_name": "infra:schema:get_versions", "service_name": "compactor", "span_status": "UNSET", "start_time": 1751444644327758300, "trace_id": "b1eeb579ae863bdf9408e7d64c02d5d1" }, "service_name": [ { "count": 1, "service_name": "compactor" } ], "spans": [1, 0], "start_time": 1751444644327758300, "trace_id": "b1eeb579ae863bdf9408e7d64c02d5d1" } ] } ``` -------------------------------- ### Run Standard Python Logging Example Source: https://openobserve.ai/docs/user-guide/data-processing/opentelemetry/openobserve-python-sdk.md Execute the example script to demonstrate logs using the standard Python logging handler. Ensure environment variables are set before running. ```bash python examples/logs_example.py ``` -------------------------------- ### Full Etcd Configuration with Temporary Command Source: https://openobserve.ai/docs/administration/maintenance/operator-guide/etcd-restore.md An example of the complete etcd configuration in values.yaml after adding the temporary command and disabling probes. This ensures etcd can be started without immediate restarts. ```yaml etcd: enabled: true # if true then etcd will be deployed as part of openobserve externalUrl: "my_custom_host.com:2379" # if bundled is false then this is required replicaCount: 3 # if bundled is true then this is required. should be odd number auth: token: enabled: false rbac: create: false allowNoneAuthentication: true rootPassword: "" logLevel: "info" extraEnvVars: - name: ETCD_AUTO_COMPACTION_RETENTION value: "1" command: ["/bin/bash", "-c", "while true; do sleep 1; done"] livenessProbe: enabled: false readinessProbe: enabled: false ``` -------------------------------- ### List All Subcommands with Help Source: https://openobserve.ai/docs/administration/maintenance/operator-guide/cli-commands.md Run `./openobserve --help` to get a comprehensive list of all available subcommands and their general usage. This is the primary way to discover available CLI operations. ```bash ./openobserve --help ``` -------------------------------- ### Install BeeAI and OpenObserve SDKs Source: https://openobserve.ai/docs/integration/ai/frameworks/beeai.md Install the necessary Python packages for BeeAI, OpenAI, OpenObserve telemetry, and environment variable loading. ```shell pip install beeai-framework openai openobserve-telemetry-sdk python-dotenv ``` -------------------------------- ### OpenObserve Tracing Hook Setup Source: https://openobserve.ai/docs/integration/ai/claude-code-tracing.md This Python code sets up a hook for OpenObserve tracing. It handles environment variable configuration, state management, and logging for tracing data. Ensure OpenObserve libraries are installed. ```python import json import os import socket import sys import time import hashlib from dataclasses import dataclass from datetime import datetime, timezone from pathlib import Path from typing import Any, Dict, List, Optional, Tuple # --- OpenObserve / OpenTelemetry import (fail-open) --- try: from openobserve import openobserve_init_traces, openobserve_flush, openobserve_shutdown from opentelemetry import trace except Exception: sys.exit(0) # --- Paths --- STATE_DIR = Path.home() / ".claude" / "state" LOG_FILE = STATE_DIR / "openobserve_hook.log" STATE_FILE = STATE_DIR / "openobserve_state.json" LOCK_FILE = STATE_DIR / "openobserve_state.lock" DEBUG = os.environ.get("CC_OPENOBSERVE_DEBUG", "").lower() == "true" MAX_CHARS = int(os.environ.get("CC_OPENOBSERVE_MAX_CHARS", "20000")) USER_ID = os.environ.get("OPENOBSERVE_USER_ID") or None HISTORY_SIZE = int(os.environ.get("OPENOBSERVE_HISTORY_SIZE", "1000")) HISTORY_MAX_AGE_DAYS = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_AGE_DAYS", "7")) HISTORY_MAX_SIZE_BYTES = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_SIZE_BYTES", "1048576")) HISTORY_MAX_AGE_SECONDS = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_AGE_SECONDS", "86400")) HISTORY_MAX_SIZE_BYTES_PER_ITEM = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_SIZE_BYTES_PER_ITEM", "10240")) HISTORY_MAX_SIZE_CHARS_PER_ITEM = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_SIZE_CHARS_PER_ITEM", "2000")) HISTORY_MAX_SIZE_CHARS = int(os.environ.get("OPENOBSERVE_HISTORY_MAX_SIZE_CHARS", "20000")) HISTORY_MAX_SIZE_CHARS_PER_ITEM_DEFAULT = 2000 HISTORY_MAX_SIZE_CHARS_DEFAULT = 20000 HISTORY_MAX_SIZE_BYTES_PER_ITEM_DEFAULT = 1024 HISTORY_MAX_SIZE_BYTES_DEFAULT = 1048576 HISTORY_MAX_AGE_SECONDS_DEFAULT = 86400 HISTORY_MAX_AGE_DAYS_DEFAULT = 7 HISTORY_MAX_SIZE_DEFAULT = 1000 HOSTNAME = socket.gethostname() # ----------------- Logging ----------------- def _log(level: str, message: str) -> None: try: STATE_DIR.mkdir(parents=True, exist_ok=True) ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(LOG_FILE, "a", encoding="utf-8") as f: f.write(f"{ts} [{level}] {message}\n") except Exception: # Never block pass def debug(msg: str) -> None: if DEBUG: _log("DEBUG", msg) def info(msg: str) -> None: _log("INFO", msg) def warn(msg: str) -> None: _log("WARN", msg) def error(msg: str) -> None: _log("ERROR", msg) # ----------------- State locking (best-effort) ----------------- class FileLock: def __init__(self, path: Path, timeout_s: float = 2.0): self.path = path self.timeout_s = timeout_s self._fh = None def __enter__(self): STATE_DIR.mkdir(parents=True, exist_ok=True) self._fh = open(self.path, "a+", encoding="utf-8") try: import fcntl # Unix only deadline = time.time() + self.timeout_s while True: try: fcntl.flock(self._fh.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) break except BlockingIOError: if time.time() > deadline: break time.sleep(0.05) except Exception: # If locking isn't available, proceed without it. pass return self def __exit__(self, exc_type, exc, tb): if self._fh is None: return try: import fcntl fcntl.flock(self._fh.fileno(), fcntl.LOCK_UN) except Exception: pass try: self._fh.close() except Exception: pass def load_state() -> Dict[str, Any]: try: if not STATE_FILE.exists(): return {} return json.loads(STATE_FILE.read_text(encoding="utf-8")) except Exception: return {} def save_state(state: Dict[str, Any]) -> None: try: STATE_DIR.mkdir(parents=True, exist_ok=True) tmp = STATE_FILE.with_suffix(".tmp") tmp.write_text(json.dumps(state, indent=2, sort_keys=True), encoding="utf-8") os.replace(tmp, STATE_FILE) except Exception as e: debug(f"save_state failed: {e}") STATE_MAX_AGE_DAYS = 7 ``` -------------------------------- ### Aggregation Cache File Naming Convention Source: https://openobserve.ai/docs/user-guide/account-administration/management/aggregation-cache.md This example shows the file naming convention for cached aggregation results, reflecting the start and end timestamps of the partition. It is useful for understanding how cached data is organized on disk. ```text /data/openobserve/cache/aggregations/default/logs/oly/ 13018130667245808899_30/ 1756116000000000_1756117800000000.arrow ``` -------------------------------- ### Run OpenAI Tracing Example Source: https://openobserve.ai/docs/user-guide/data-processing/opentelemetry/openobserve-python-sdk.md Execute the example script to demonstrate traces with the OpenAI instrumentation. Ensure environment variables are set before running. ```bash python examples/openai_example.py ``` -------------------------------- ### Example Response for Get Stream Schema Source: https://openobserve.ai/docs/reference/api/stream/schema.md This JSON object illustrates the structure of the response when retrieving schema, stats, and settings for a stream. It includes stream metadata, performance statistics, field definitions, and configuration settings. ```json { "name": "k8s", "storage_type": "s3", "stream_type": "logs", "stats": { "doc_time_min": 1673715046856933, "doc_time_max": 1673849134852901, "doc_num": 3300000, "file_num": 16, "storage_size": 3323.5, "compressed_size": 11.42 }, "schema": [ { "name": "_timestamp", "type": "Int64" }, { "name": "kubernetes.annotations.kubernetes.io/psp", "type": "Utf8" }, ], "settings": { "partition_keys": {}, "full_text_search_keys": ["log"] } } ``` -------------------------------- ### Install Exa and OpenObserve SDKs Source: https://openobserve.ai/docs/integration/ai/tools/exa.md Install the necessary Python packages for Exa integration and OpenObserve telemetry. ```shell pip install openobserve-telemetry-sdk exa-py opentelemetry-api python-dotenv ``` -------------------------------- ### Using histogram() with COUNT() Aggregate Source: https://openobserve.ai/docs/reference/sql-functions/aggregate.md This example demonstrates how to use the histogram() function with COUNT() to group log data into 30-second intervals and count the number of logs in each interval. The results are ordered by the interval's start time. ```sql SELECT histogram(_timestamp, '30 seconds') AS key, COUNT(*) AS num FROM "default" GROUP BY key ORDER BY key ``` -------------------------------- ### Install SDK using requirements.txt Source: https://openobserve.ai/docs/user-guide/data-processing/opentelemetry/openobserve-python-sdk.md Install the OpenObserve Python SDK using a requirements.txt file, which is a common method for managing project dependencies. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Fluent Bit on Ubuntu Source: https://openobserve.ai/docs/integration/devops/ansible.md Installs Fluent Bit using the official installation script. Verify the installation by checking the Fluent Bit version. ```bash curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh ``` ```bash fluent-bit --version ``` -------------------------------- ### O2 CLI Resource-First Command Examples Source: https://openobserve.ai/docs/administration/configuration/o2-cli/o2-cli.md Examples of using the O2 CLI with resource-first syntax for managing resources like templates, dashboards, pipelines, and functions. ```bash o2 template list o2 dashboard get 123456 o2 template create -f template.yaml o2 pipeline update -f pipeline.yaml o2 function delete my-function ``` -------------------------------- ### O2 CLI kubectl-Style Command Examples Source: https://openobserve.ai/docs/administration/configuration/o2-cli/o2-cli.md Examples of using the O2 CLI with kubectl-style syntax (verb-first) for managing resources like templates, dashboards, pipelines, and functions. ```bash o2 list template o2 get dashboard 123456 o2 create template -f template.yaml o2 update pipeline -f pipeline.yaml o2 delete function my-function ``` -------------------------------- ### Install NATS Dependencies Source: https://openobserve.ai/docs/integration/message-brokers/nats.md Installs necessary dependencies for NATS server installation on Debian-based systems. ```bash sudo apt update && sudo apt upgrade -y sudo apt install -y wget unzip ``` -------------------------------- ### Install Codename Goose CLI Source: https://openobserve.ai/docs/integration/ai/no-code/codename-goose.md Installs the Goose CLI using a shell script. Ensure you have curl installed. ```shell curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | bash ``` -------------------------------- ### Load Sample Data into Self-Hosted OpenObserve Source: https://openobserve.ai/docs/enterprise-setup/google-gke.md Loads the downloaded sample Kubernetes logs into a self-hosted OpenObserve installation using cURL. Replace placeholders with your email, password, and host details. ```bash # Replace credentials with the values you set in Step 6a. curl -u "your-email@example.com:supercomplexpass12" \ -H "Content-Type: application/json" \ http://localhost:5080/api/default/default/_json \ -d "@k8slog_json.json" ``` -------------------------------- ### Install CloudNativePG Source: https://openobserve.ai/docs/enterprise-setup/azure-aks.md Installs the CloudNativePG operator, which is required for managing PostgreSQL instances within your cluster. This is a cluster-wide installation. ```bash kubectl apply --server-side -f \ https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.22/releases/cnpg-1.22.1.yaml ``` -------------------------------- ### Start NATS Server with Configuration File Source: https://openobserve.ai/docs/integration/message-brokers/nats.md Starts the NATS server using the specified configuration file. ```bash nats-server -c /etc/nats/nats.conf ``` -------------------------------- ### LogQL to OpenObserve SQL Translation Examples Source: https://openobserve.ai/docs/migration/migrate-from-grafana-to-openobserve/dashboards-and-alerts.md Examples demonstrating the translation of LogQL queries to OpenObserve SQL syntax for log analysis. ```sql SELECT * FROM default WHERE service = 'api' AND match_all('error') ``` ```sql SELECT count(*) FROM default WHERE service = 'api' AND level = 'error' ``` ```sql SELECT count(*) / 300 FROM default WHERE job = 'nginx' AND match_all('timeout') ``` -------------------------------- ### Install O2 CLI with Homebrew Source: https://openobserve.ai/docs/administration/configuration/o2-cli/o2-cli.md Install the O2 CLI using Homebrew on macOS. This is the recommended installation method. ```bash brew tap openobserve/tap brew install o2 ```