### Example Axiom Event Structure (JSON) Source: https://axiom.co/docs/getting-started-guide/getting-started An example of an event structure that follows the JSON specification, illustrating common fields like service, severity, duration, customer_id, tags, and metadata. Events are individual data points sent to Axiom. ```json { "service": "api-http", "severity": "error", "duration": 231, "customer_id": "ghj34g32poiu4", "tags": ["aws-east-1", "zone-b"], "metadata": { "version": "3.1.2" } } ``` -------------------------------- ### Example Environment Variables for Axiom API (Manual Setup) (Bash) Source: https://axiom.co/docs/guides/opentelemetry-nextjs Example `.env` file content showing how to define `API_TOKEN` and `DATASET_NAME` environment variables required for the OpenTelemetry exporter to authenticate and specify the target dataset in Axiom when using the manual setup. ```bash API_TOKEN=xaat-123 DATASET_NAME=my-dataset ``` -------------------------------- ### Example Environment Variables for Axiom API (@vercel/otel Setup) (Bash) Source: https://axiom.co/docs/guides/opentelemetry-nextjs Example `.env` file content showing how to define `API_TOKEN` and `DATASET_NAME` environment variables required for the OpenTelemetry exporter to authenticate and specify the target dataset in Axiom when using the `@vercel/otel` setup. ```bash API_TOKEN=xaat-123 DATASET_NAME=my-dataset ``` -------------------------------- ### Installing OpenTelemetry Go Dependencies Source: https://axiom.co/docs/guides/opentelemetry-go Installs the required OpenTelemetry Go SDK packages, including the core SDK, OTLP HTTP trace exporter, resource management, trace SDK, semantic conventions, and HTTP instrumentation libraries using the `go get` command. ```bash go get go.opentelemetry.io/otel go get go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp go get go.opentelemetry.io/otel/sdk/resource go get go.opentelemetry.io/otel/sdk/trace go get go.opentelemetry.io/otel/semconv/v1.24.0 go get go.opentelemetry.io/otel/trace go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp go get go.opentelemetry.io/otel/propagation ``` -------------------------------- ### Install Axiom Loki Proxy using go get (Bash) Source: https://axiom.co/docs/send-data/loki-multiplexer Installs the Axiom Loki Proxy command-line tool directly using the Go toolchain's `go get` command. Requires Go to be installed and configured. ```Bash go get -u github.com/axiomhq/axiom-loki-proxy/cmd/axiom-loki-proxy ``` -------------------------------- ### Installing OpenTelemetry Dependencies with @vercel/otel (Bash) Source: https://axiom.co/docs/guides/opentelemetry-nextjs Command to install necessary OpenTelemetry packages including `@vercel/otel`, `@opentelemetry/exporter-trace-otlp-http`, and `@opentelemetry/sdk-trace-node` for simplified setup. ```bash npm install @vercel/otel @opentelemetry/exporter-trace-otlp-http @opentelemetry/sdk-trace-node ``` -------------------------------- ### Install Axiom Syslog Proxy with Go Source: https://axiom.co/docs/send-data/syslog-proxy Command to install the Axiom Syslog Proxy using the Go `go get` command. ```Shell go install github.com/axiomhq/axiom-syslog-proxy/cmd/axiom-syslog-proxy@latest ``` -------------------------------- ### Installing OpenTelemetry Dependencies Manually (Bash) Source: https://axiom.co/docs/guides/opentelemetry-nextjs Command to install necessary OpenTelemetry packages including `@opentelemetry/sdk-node`, `@opentelemetry/exporter-trace-otlp-http`, `@opentelemetry/resources`, `@opentelemetry/semantic-conventions`, and `@opentelemetry/sdk-trace-node` for manual setup without `@vercel/otel`. ```bash npm install @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node ``` -------------------------------- ### Integrating Auto-Instrumentation Setup (Java) Source: https://axiom.co/docs/guides/opentelemetry-java Shows the main application entry point (`Main.java`) where the `AutoInstrumentationSetup.setup()` method is called before the main application logic (`DiceRollerApp.main`) begins, ensuring instrumentation is active from the start. ```java // Main.java package com.example; public class Main { public static void main(String[] args) { AutoInstrumentationSetup.setup(); // Initialize OpenTelemetry auto-instrumentation DiceRollerApp.main(args); // Start the application logic } } ``` -------------------------------- ### Install Axiom CLI from Source Source: https://axiom.co/docs/reference/cli Clones the Axiom CLI repository, navigates into the directory, and builds/installs the binary using `make install`. Requires a Go environment and make. ```bash git clone https://github.com/axiomhq/cli.git cd cli make install # Build and install binary into $GOPATH ``` -------------------------------- ### Install Axiom CLI using Go Source: https://axiom.co/docs/reference/cli Installs the latest version of the Axiom CLI using the Go toolchain. Requires Go version 1.16 or higher. ```bash go install github.com/axiomhq/cli/cmd/axiom@latest ``` -------------------------------- ### Initializing OpenTelemetry Tracer Source: https://axiom.co/docs/guides/opentelemetry-nodejs Imports the OpenTelemetry trace API and gets a configured tracer instance, typically used in an instrumentation setup file. ```js // Assuming OpenTelemetry SDK is already configured const { trace } = require('@opentelemetry/api'); const tracer = trace.getTracer('example-tracer'); ``` -------------------------------- ### Start Winlogbeat Service (PowerShell) Source: https://axiom.co/docs/send-data/elastic-beats Starts the installed Winlogbeat Windows service using the `Start-Service` cmdlet. ```powershell PS C:\Program Files\Winlogbeat> Start-Service winlogbeat ``` -------------------------------- ### Installing OpenTelemetry Dependencies (Bash) Source: https://axiom.co/docs/guides/opentelemetry-dotnet Command to add necessary OpenTelemetry NuGet packages to the .NET project using the `dotnet add package` command. Lists specific packages and versions required for OpenTelemetry setup, including exporters and instrumentation. ```Bash dotnet add package OpenTelemetry --version 1.7.0 dotnet add package OpenTelemetry.Exporter.Console --version 1.7.0 dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol --version 1.7.0 dotnet add package OpenTelemetry.Extensions.Hosting --version 1.7.0 dotnet add package OpenTelemetry.Instrumentation.AspNetCore --version 1.7.1 dotnet add package OpenTelemetry.Instrumentation.Http --version 1.6.0-rc.1 ``` -------------------------------- ### Starting Node.js App in Production Source: https://axiom.co/docs/guides/opentelemetry-nodejs Starts the built Node.js application in production mode using the `npm start` command after the build process is complete. ```bash npm start ``` -------------------------------- ### Install Axiom CLI using Homebrew Source: https://axiom.co/docs/reference/cli Adds the Axiom Homebrew tap and installs the Axiom CLI package. This makes the `axiom` command available globally. ```bash brew tap axiomhq/tap brew install axiom ``` -------------------------------- ### Install Axiom Syslog Proxy with Homebrew Source: https://axiom.co/docs/send-data/syslog-proxy Commands to add the Axiom Homebrew tap and install the syslog proxy using Homebrew. ```Shell brew tap axiomhq/tap brew install axiom-syslog-proxy ``` -------------------------------- ### Install Axiom Grafana Plugin via CLI - Bash Source: https://axiom.co/docs/apps/grafana This command uses the Grafana command-line interface to install the Axiom data source plugin. It is used for local Grafana installations. ```bash grafana-cli plugins install axiomhq-axiom-datasource ``` -------------------------------- ### Installing OpenTelemetry Auto-Instrumentation Source: https://axiom.co/docs/guides/opentelemetry-nodejs Installs the necessary npm package containing pre-built auto-instrumentation libraries for common Node.js frameworks and libraries. ```bash npm install @opentelemetry/auto-instrumentations-node ``` -------------------------------- ### Installing Axiom React/Logging Libraries - Shell Source: https://axiom.co/docs/send-data/react Command to install the `@axiomhq/logging` and `@axiomhq/react` packages using npm, saving them as dependencies in the project. ```sh npm install --save @axiomhq/logging @axiomhq/react ``` -------------------------------- ### Installing Node.js Project Dependencies Source: https://axiom.co/docs/guides/opentelemetry-nodejs This command installs all required project dependencies listed in the `dependencies` and `devDependencies` sections of the `package.json` file. ```bash npm install ``` -------------------------------- ### Install Axiom Node.js Library via npm Source: https://axiom.co/docs/restapi/query Command to install the official Axiom Node.js client library using npm, which provides bindings for the Axiom API. ```Shell npm install @axiomhq/js ``` -------------------------------- ### trim_start() Example - Kusto Source: https://axiom.co/docs/apl/scalar-functions/string-functions Example using `trim_start()` to remove the substring "github" from the beginning of the 'repo' field in the 'github-issues-event' table. ```kusto ['github-issues-event'] | project remove_cutset = trim_start( "github", repo) ``` -------------------------------- ### Setting up HTTP Server with OpenTelemetry Tracing in Go Source: https://axiom.co/docs/guides/opentelemetry-go This code snippet demonstrates how to initialize OpenTelemetry tracing, set up a basic HTTP server using net/http, and integrate OpenTelemetry instrumentation using otelhttp. It includes signal handling for graceful shutdown and defines example request handlers (/rolldice, /roll_with_link) that create spans and span links. ```Go // main.go package main import ( "context" "fmt" "log" "math/rand" "net" "net/http" "os" "os/signal" "time" // OpenTelemetry imports for tracing and observability. "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" ) // main function starts the application and handles run function errors. func main() { if err := run(); err != nil { log.Fatalln(err) } } // run sets up signal handling, tracer initialization, and starts an HTTP server. func run() error { // Creating a context that listens for the interrupt signal from the OS. ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() // Initializes tracing and returns a function to shut down OpenTelemetry cleanly. otelShutdown, err := SetupTracer() if err != nil { return err } defer func() { if shutdownErr := otelShutdown(ctx); shutdownErr != nil { log.Printf("failed to shutdown OpenTelemetry: %v", shutdownErr) // Log fatal errors during server shutdown } }() // Configuring the HTTP server settings. srv := &http.Server{ Addr: ":8080", // Server address BaseContext: func(_ net.Listener) context.Context { return ctx }, ReadTimeout: 5 * time.Second, // Server read timeout WriteTimeout: 15 * time.Second, // Server write timeout Handler: newHTTPHandler(), // HTTP handler } // Starting the HTTP server in a new goroutine. go func() { if err := srv.ListenAndServe(); err != http.ErrServerClosed { log.Fatalf("HTTP server ListenAndServe: %v", err) } }() // Wait for interrupt signal to gracefully shut down the server with a timeout context. <-ctx.Done() shutdownCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() // Ensures cancel function is called on exit if err := srv.Shutdown(shutdownCtx); err != nil { log.Fatalf("HTTP server Shutdown: %v", err) // Log fatal errors during server shutdown } return nil } // newHTTPHandler configures the HTTP routes and integrates OpenTelemetry. func newHTTPHandler() http.Handler { mux := http.NewServeMux() // HTTP request multiplexer // Wrapping the handler function with OpenTelemetry instrumentation. handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) { handler := otelhttp.WithRouteTag(pattern, http.HandlerFunc(handlerFunc)) mux.Handle(pattern, handler) // Associate pattern with handler } // Registering route handlers with OpenTelemetry instrumentation handleFunc("/rolldice", rolldice) handleFunc("/roll_with_link", rollWithLink) handler := otelhttp.NewHandler(mux, "/") return handler } // rolldice handles the /rolldice route by generating a random dice roll. func rolldice(w http.ResponseWriter, r *http.Request) { _, span := otel.Tracer("example-tracer").Start(r.Context(), "rolldice") defer span.End() // Generating a random dice roll. randGen := rand.New(rand.NewSource(time.Now().UnixNano())) roll := 1 + randGen.Intn(6) // Writing the dice roll to the response. fmt.Fprintf(w, "Rolled a dice: %d\n", roll) } // rollWithLink handles the /roll_with_link route by creating a new span with a link to the parent span. func rollWithLink(w http.ResponseWriter, r *http.Request) { ctx, span := otel.Tracer("example-tracer").Start(r.Context(), "roll_with_link") defer span.End() /** * Create a new span for rolldice with a link to the parent span. * This link helps correlate events that are related but not directly a parent-child relationship. */ rollDiceCtx, rollDiceSpan := otel.Tracer("example-tracer").Start(ctx, "rolldice", trace.WithLinks(trace.Link{ SpanContext: span.SpanContext(), Attributes: nil, }), ) defer rollDiceSpan.End() // Generating a random dice roll linked to the parent context. randGen := rand.New(rand.NewSource(time.Now().UnixNano())) roll := 1 + randGen.Intn(6) // Writing the linked dice roll to the response. fmt.Fprintf(w, "Dice roll result (with link): %d\n", roll) // Use the rollDiceCtx if needed. _ = rollDiceCtx } ``` -------------------------------- ### Install Axiom Loki Proxy using Homebrew (Bash) Source: https://axiom.co/docs/send-data/loki-multiplexer Installs and updates the Axiom Loki Proxy using the Homebrew package manager. Requires Homebrew to be installed on your system. ```Bash brew tap axiomhq/tap brew install axiom-loki-proxy brew update brew upgrade axiom-loki-proxy ``` -------------------------------- ### Install Winlogbeat Windows Service (PowerShell) Source: https://axiom.co/docs/send-data/elastic-beats Navigates to the Winlogbeat directory and executes the installation script to set up Winlogbeat as a Windows service. ```powershell PS C:\Users\Administrator> cd C:\Program Files\Winlogbeat PS C:\Program Files\Winlogbeat> .\install-service-winlogbeat.ps1 ``` -------------------------------- ### Initializing Axiom Logrus Adapter with Client Options (Go) Source: https://axiom.co/docs/guides/logrus Initializes a new Axiom Logrus adapter hook and configures the underlying Axiom client using `adapter.SetClientOptions`. This example demonstrates setting the client's authentication using a personal API token via `axiom.SetPersonalTokenConfig`. Replace "AXIOM_TOKEN" with your actual Axiom API token. Requires importing both the main `axiom` package and the `adapter` package. ```Go import ( "github.com/axiomhq/axiom-go/axiom" adapter "github.com/axiomhq/axiom-go/adapters/logrus" ) // ... hook, err := adapter.New( adapter.SetClientOptions( axiom.SetPersonalTokenConfig("AXIOM_TOKEN") ) ) ``` -------------------------------- ### Example Slack Notifier Configuration (YAML) Source: https://axiom.co/docs/restapi/endpoints/updateNotifier Provides an example configuration block for a Slack notifier using a webhook URL. ```YAML slack: slackUrl: >- https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX ``` -------------------------------- ### Create Docker Startup Script (Shell/Dockerfile) Source: https://axiom.co/docs/guides/send-logs-from-apache-log4j This Dockerfile RUN instruction creates an executable shell script named `start.sh` inside the image. The script first starts the Fluentd daemon in the background, waits for 5 seconds, and then executes the Java application with a specified Log4j configuration file. ```Dockerfile RUN echo '#!/bin/sh\n\fluentd -c /etc/fluent/fluent.conf &\n\sleep 5\n\java -Dlog4j.configurationFile=log4j2.xml -jar log4j-axiom-test-1.0-SNAPSHOT.jar\n'\ > /usr/src/app/start.sh && chmod +x /usr/src/app/start.sh ``` -------------------------------- ### Configuring Axiom Apex Adapter with Client Options in Go Source: https://axiom.co/docs/guides/apex Shows how to initialize the Axiom apex/log adapter using `adapter.New` and configure the underlying Axiom client with specific options, such as setting a personal token using `axiom.SetPersonalTokenConfig`. This allows for manual client configuration. ```Go import ( "github.com/axiomhq/axiom-go/axiom" adapter "github.com/axiomhq/axiom-go/adapters/apex" ) // ... handler, err := adapter.New( adapter.SetClientOptions( axiom.SetPersonalTokenConfig("AXIOM_TOKEN") ) ) ``` -------------------------------- ### Discord Bot Token Example (YAML) Source: https://axiom.co/docs/restapi/endpoints/createNotifier Example of a Discord bot token used for authenticating the bot when sending messages to a channel. The token typically starts with 'Bot ' followed by the token string. ```YAML Bot 123456789012345678 ``` -------------------------------- ### Array Slicing - Start and End (Expression) Source: https://axiom.co/docs/query-data/virtual-fields Shows how to extract a slice from an array (`myArray`) using both start and end indices (exclusive of the end index). The example `myArray[1:5]` extracts elements from index 1 up to (but not including) index 5. ```Expression myArray[1:5] == [2, 3, 4] ``` -------------------------------- ### Ingest Events and Query Data with Axiom Go SDK - Go Source: https://axiom.co/docs/guides/go This comprehensive example shows how to initialize an Axiom client, ingest sample events into a specified dataset, and then perform a query against that dataset, printing the results. It includes error handling for client creation, ingestion, and querying. ```go package main import ( "context" "fmt" "log" "time" "github.com/axiomhq/axiom-go/axiom" "github.com/axiomhq/axiom-go/axiom/ingest" "github.com/axiomhq/axiom-go/axiom/query" ) func main() { ctx := context.Background() client, err := axiom.NewClient() if err != nil { log.Fatal(err) } if _, err = client.IngestEvents(ctx, "my-dataset", []axiom.Event{ {ingest.TimestampField: time.Now(), "foo": "bar"}, {ingest.TimestampField: time.Now(), "bar": "foo"}, }); err != nil { log.Fatal(err) } res, err := client.Query(ctx, "['my-dataset'] | where foo == 'bar' | limit 100") if err != nil { log.Fatal(err) } else if res.Status.RowsMatched == 0 { log.Fatal("No matches found") } rows := res.Tables[0].Rows() if err := rows.Range(ctx, func(_ context.Context, row query.Row) error { _, err := fmt.Println(row) return err }); err != nil { log.Fatal(err) } } ``` -------------------------------- ### Example Response for Getting Axiom Annotations - JSON Source: https://axiom.co/docs/query-data/annotate-charts This JSON snippet provides an example of the response received when successfully retrieving a list of Axiom annotations. Each object in the array represents an annotation with details like datasets, description, ID, time, title, type, and URL. ```json [ { "datasets": ["my-dataset"], "description": "Deploy new feature to the navigation component", "id": "ann_234", "time": "2024-03-17T01:15:45.232Z", "title": "Production deployment", "type": "deploy", "url": "https://example.com" }, { "datasets": ["my-dataset"], "description": "Deploy new feature to the sales form", "id": "ann_123", "time": "2024-03-18T08:39:28.382Z", "title": "Production deployment", "type": "deploy", "url": "https://example.com" } ] ``` -------------------------------- ### Set Docker Entrypoint (Dockerfile) Source: https://axiom.co/docs/guides/send-logs-from-apache-log4j This Dockerfile command sets the default command to be executed when the container starts. It specifies the path to the `start.sh` script created earlier, which will initiate both Fluentd and the Java application. ```Dockerfile CMD ["/usr/src/app/start.sh"] ``` -------------------------------- ### trim_start_regex() Example - Kusto Source: https://axiom.co/docs/apl/scalar-functions/string-functions Example using `trim_start_regex()` to remove leading matches of the regular expression "github" from the 'repo' field in the 'github-issues-event' table. ```kusto ['github-issues-event'] | project remove_cutset = trim_start_regex( "github", repo) ``` -------------------------------- ### Get OpenTelemetry Tracer in Next.js Source: https://axiom.co/docs/guides/opentelemetry-nextjs Set up and retrieve a tracer from the OpenTelemetry API within your Next.js application to start and manage spans. ```js import { trace } from '@opentelemetry/api'; const tracer = trace.getTracer('nextjs-app'); ``` -------------------------------- ### OpenAPI Spec: List Datasets (GET /datasets) Source: https://axiom.co/docs/restapi/endpoints/getDatasets This YAML snippet defines the OpenAPI specification for the GET /datasets endpoint. It details the path, method, security, parameters, and expected responses (200 Success with dataset list, 403 Forbidden), including schema definitions and examples for the Dataset object. ```yaml paths: path: /datasets method: get servers: - url: https://api.axiom.co/v2/ request: security: [] parameters: path: {} query: {} header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: array items: allOf: - $ref: '#/components/schemas/Dataset' example: - created: '2020-01-01T00:00:00Z' description: This is an example dataset id: example-dataset name: example-dataset who: John Doe - created: '2020-02-01T00:00:00Z' description: This is an example dataset id: example-dataset-2 name: example-dataset-2 who: Foo Bar examples: example: value: - created: '2020-01-01T00:00:00Z' description: This is an example dataset id: example-dataset name: example-dataset who: John Doe - created: '2020-02-01T00:00:00Z' description: This is an example dataset id: example-dataset-2 name: example-dataset-2 who: Foo Bar description: Success '403': application/json: schemaArray: - type: object properties: code: allOf: - type: string message: allOf: - type: string example: code: 403 message: Forbidden examples: example: value: code: 403 message: Forbidden description: Forbidden deprecated: false type: path components: schemas: Dataset: type: object required: - id - name - description - created - who properties: canWrite: description: Whether this dataset has write access type: boolean created: description: The RFC3339-formatted time when the dataset was created. type: string format: date-time description: description: Dataset description type: string id: description: Dataset ID type: string name: description: Unique dataset name type: string retentionDays: description: Number of days to retain data in the dataset type: integer x-omitempty: false sharedByOrg: description: ID of the org that shared this resource, if it's shared type: string useRetentionPeriod: description: Whether to use the retention period type: boolean x-omitempty: false who: description: Name of the dataset creator type: string example: created: '2022-07-20T02:35:14.137Z' description: string id: string name: string who: string ``` -------------------------------- ### Take First 100 Logs (Kusto) Source: https://axiom.co/docs/apl/tutorial Returns the first 100 entries from the 'sample-http-logs' dataset. ```kusto ['sample-http-logs'] | take 100 ``` -------------------------------- ### Getting Filtered Axiom Annotations via API - Bash Source: https://axiom.co/docs/query-data/annotate-charts This snippet shows how to retrieve annotations filtered by a specific time interval and/or a list of datasets using query parameters in the GET request. Parameters include `start`, `end` (ISO timestamps), and `datasets` (comma-separated list). ```bash curl -X 'GET' 'https://api.axiom.co/v2/annotations?start=2024-03-16T00:00:00.000Z&end=2024-03-19T23:59:59.999Z&datasets=my-dataset' \ -H 'Authorization: Bearer API_TOKEN' ``` -------------------------------- ### Install Axiom Go SDK - Shell Source: https://axiom.co/docs/guides/go This command installs the Axiom Go SDK package using the Go module system. It fetches the specified version from GitHub and adds it to your project's dependencies. ```shell go get github.com/axiomhq/axiom-go/axiom ``` -------------------------------- ### Initializing a Go Module Source: https://axiom.co/docs/guides/opentelemetry-go Initializes a new Go module in the current directory by creating a `go.mod` file. Replace `` with your project's desired module path, typically a repository URL. ```bash go mod init ``` -------------------------------- ### OpenAPI Path Definition for GET /monitors (v2) Source: https://axiom.co/docs/restapi/endpoints/getMonitors Defines the OpenAPI specification for the GET method on the `/v2/monitors` endpoint. It includes details on security (OAuth2), parameters (none required for path, query, header, or cookie), and the expected 200 OK response structure, which returns an array of `MonitorWithId` objects with an example. ```yaml paths: path: /monitors method: get servers: - url: https://api.axiom.co/v2/ request: security: - title: Auth parameters: query: {} header: Authorization: type: oauth2 cookie: {} parameters: path: {} query: {} header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: array items: allOf: - $ref: '#/components/schemas/MonitorWithId' examples: example: value: - alertOnNoData: true aplQuery: '| where severity = ''error'' | count() > 100' columnName: cpu_usage compareDays: 7 createdAt: '2024-03-20T10:00:00Z' createdBy: usr_789xyz description: Monitors CPU usage and alerts when it exceeds 90% disabled: false disabledUntil: '2024-04-01T00:00:00Z' intervalMinutes: 5 name: Production CPU Monitor notifierIds: - notify_slack_prod - notify_email_oncall notifyByGroup: false notifyEveryRun: false operator: Above rangeMinutes: 5 resolvable: true secondDelay: 300 skipResolved: false threshold: 90 tolerance: 10 triggerAfterNPositiveResults: 2 triggerFromNRuns: 3 type: Threshold id: mon_xyz789 description: Monitor deprecated: false type: path ``` -------------------------------- ### Define GET /rbac/roles Endpoint in OpenAPI v2 Source: https://axiom.co/docs/restapi/endpoints/listRoles This snippet defines the OpenAPI specification for the GET /rbac/roles endpoint. It details the path, method, server URL, security scheme (OAuth2), empty request parameters/body, and the successful 200 response structure. The response schema is an array of RoleWithID objects, including an example response payload. ```yaml paths: path: /rbac/roles method: get servers: - url: https://api.axiom.co/v2/ request: security: - title: Auth parameters: query: {} header: Authorization: type: oauth2 cookie: {} parameters: path: {} query: {} header: {} cookie: {} body: {} response: '200': application/json: schemaArray: - type: array items: allOf: - $ref: '#/components/schemas/RoleWithID' examples: example: value: - datasetCapabilities: {} description: members: - name: orgCapabilities: annotations: - create apiTokens: - create auditLog: - read billing: - read dashboards: - create datasets: - create endpoints: - create flows: - create integrations: - create monitors: - create notifiers: - create rbac: - create sharedAccessKeys: - read users: - create views: - create viewCapabilities: {} id: description: A list of roles was successfully retrieved deprecated: false type: path ``` -------------------------------- ### Initialize and Use Axiom Rust Client Source: https://axiom.co/docs/guides/rust Demonstrates how to initialize the Axiom client using either a token or environment variables, create a dataset, ingest data, query data, and delete the dataset asynchronously using the `tokio` runtime. ```Rust use axiom_rs::Client; use serde_json::json; #[tokio::main] async fn main() -> Result<(), Box> { // Build your client by providing a personal token and an org id: let client = Client::builder() .with_token("API_TOKEN") .build()?; // Alternatively, auto-configure the client from the environment variable AXIOM_TOKEN: let client = Client::new()?; client.datasets().create("DATASET_NAME", "").await?; client .ingest( "DATASET_NAME", vec![json!({ "foo": "bar", })], ) .await?; let res = client .query(r#"['DATASET_NAME'] | where foo == "bar" | limit 100"# , None) .await?; println!("{:?}", res); client.datasets().delete("DATASET_NAME").await?; Ok(()) } ``` -------------------------------- ### Install Axiom Syslog Proxy from Source Source: https://axiom.co/docs/send-data/syslog-proxy Commands to clone the GitHub repository, navigate into the directory, and build/install the proxy from source. ```Shell git clone https://github.com/axiomhq/axiom-syslog-proxy.git cd axiom-syslog-proxy make install ``` -------------------------------- ### APL: Use Case - Analyze Web Log Geo Traffic Source: https://axiom.co/docs/apl/scalar-functions/ip-functions/geo-info-from-ip-address Example APL query demonstrating how to use `geo_info_from_ip_address` to get geo info for a specific IP address in sample web logs. ```kusto ['sample-http-logs'] | extend geo_info = geo_info_from_ip_address('172.217.22.14') ``` -------------------------------- ### OpenAPI Specification for GET /notifiers and Notifier Schemas Source: https://axiom.co/docs/restapi/endpoints/getNotifiers Defines the OpenAPI specification for the GET /notifiers endpoint, including its security requirements (OAuth2), parameters, and the structure of the successful 200 response, which returns an array of NotifierWithId objects. It also includes the definitions for various notifier configuration schemas like CustomNotifierConfig, DiscordConfig, EmailConfig, etc., detailing their properties and providing examples. ```yaml paths:\n path: /notifiers\n method: get\n servers:\n - url: https://api.axiom.co/v2/\n request:\n security:\n - title: Auth\n parameters:\n query: {}\n header:\n Authorization:\n type: oauth2\n cookie: {}\n parameters:\n path: {}\n query: {}\n header: {}\n cookie: {}\n body: {}\n response:\n '200':\n application/json:\n schemaArray:\n - type: array\n items:\n allOf:\n - $ref: '#/components/schemas/NotifierWithId'\n examples:\n example:\n value:\n - createdAt: '2024-01-15T10:30:00Z'\n createdBy: alice@example.com\n disabledUntil: '2024-03-20T15:00:00Z'\n name: Production Slack Alerts\n properties:\n customWebhook:\n body: >-\n {\"alert\": \"{{.AlertName}}\", \"severity\": \"{{.Severity}}\",\n \"message\": \"{{.Message}}\"}\n headers:\n Content-Type: application/json\n X-API-Version: '1.0'\n secretHeaders:\n Authorization: Bearer {{token}}\n url: https://api.custom-service.com/alerts\n discord:\n discordChannel: '123456789012345678'\n discordToken: Bot 123456789012345678\n discordWebhook:\n discordWebhookUrl: >-\n https://discord.com/api/webhooks/123456789012345678/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n email:\n emails:\n - oncall@example.com\n - alerts@example.com\n microsoftTeams:\n microsoftTeamsUrl: >-\n https://outlook.office.com/webhook/123456789/IncomingWebhook/...\n opsgenie:\n apiKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n isEU: true\n pagerduty:\n routingKey: 1234567890abcdef1234567890abcdef\n token: u+1234567890abcdef1234567890abcdef\n slack:\n slackUrl: >-\n https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX\n webhook:\n url: https://api.example.com/webhooks/alerts\n id: notify_slack_prod\n description: Successfully retrieved list of notifiers\n deprecated: false\n type: path\ncomponents:\n schemas:\n CustomNotifierConfig:\n description: >\n Configuration for custom webhook notifications with flexible headers and\n body template.\n\n Supports variable substitution in the body template using {{.Variable}}\n syntax.\n type: object\n required:\n - url\n - body\n properties:\n body:\n description: Template for the webhook body, supports variable substitution\n type: string\n example: >-\n {\"alert\": \"{{.AlertName}}\", \"severity\": \"{{.Severity}}\", \"message\":\n \"{{.Message}}\"}\n headers:\n description: HTTP headers to include in the request\n type: object\n additionalProperties:\n type: string\n example:\n Content-Type: application/json\n X-API-Version: '1.0'\n secretHeaders:\n description: Sensitive HTTP headers (tokens, keys) that should be masked in logs\n type: object\n additionalProperties:\n type: string\n example:\n Authorization: Bearer {{token}}\n url:\n description: Custom webhook endpoint URL\n type: string\n example: https://api.custom-service.com/alerts\n DiscordConfig:\n description: Configuration for Discord notifications using bot token\n properties:\n discordChannel:\n description: Discord channel ID to send notifications\n type: string\n example: '123456789012345678'\n discordToken:\n description: Discord bot token for authentication\n type: string\n example: Bot 123456789012345678\n DiscordWebhookConfig:\n description: Configuration for Discord notifications using webhooks\n properties:\n discordWebhookUrl:\n description: Discord webhook URL\n type: string\n example: >-\n https://discord.com/api/webhooks/123456789012345678/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n EmailConfig:\n description: Configuration for email notifications\n properties:\n emails:\n description: List of email addresses to receive notifications\n type: array\n items:\n type: string\n example:\n - oncall@example.com\n - alerts@example.com\n MicrosoftTeamsConfig:\n ``` -------------------------------- ### Complete UI Configuration Data Source: https://axiom.co/docs/getting-started-guide/axiom-tour This snippet contains the full JSON object defining the theme properties (colors, sizes, styles) and the structure of the guided flows, including steps, buttons, and content references. ```JSON "backdropHighlightBorderColor":"#22194d","backdropHighlightShadow":"0 0 4px 0px rgba(255,255,255,0.1), 0 0 0 1000vw rgba(0,0,0,0.7)","backdropLightOpacity":20,"backdropMediumOpacity":60,"bannerButtonColor":"#ffffff","bannerButtonEnabled":true,"bannerButtonLink":"https://docs.navattic.com/","bannerButtonText":"Get Started","bannerButtonTextColor":"#000000","bannerColor":"#22194d","bannerEnabled":false,"bannerText":"Example CTA Banner","bannerTextColor":"#ffffff","beaconColor":"#22194d","beaconDiameterLarge":24,"beaconDiameterMedium":18,"beaconDiameterSmall":14,"buttonBgColor":"#22194d","buttonBgColorActive":"#22194d","buttonBgColorHover":"#22194d","buttonBorderColor":"#22194d","buttonBorderColorActive":"#22194d","buttonBorderColorHover":"#22194d","buttonBorderRadius":6,"buttonFontWeight":500,"buttonPaddingHorizontal":10,"buttonPaddingVertical":5,"buttonSecondaryBgColor":"#ffffff","buttonSecondaryBgColorActive":"#ffffff","buttonSecondaryBgColorHover":"#ffffff","buttonSecondaryBorderColor":"#22194d","buttonSecondaryBorderColorActive":"#22194d","buttonSecondaryBorderColorHover":"#22194d","buttonSecondaryFontWeight":500,"buttonSecondaryPaddingHorizontal":10,"buttonSecondaryPaddingVertical":5,"buttonSecondaryTextColor":"#22194d","buttonSecondaryTextColorHover":"#22194d","buttonTextColor":"#ffffff","buttonTextColorHover":"#ffffff","buttonsMarginBottom":0,"buttonsMarginTop":5,"checklistCheckmarkBgColor":"#09AA14","checklistFilter":"drop-shadow(0 3px 10.5px rgba(0,0,0,0.15)) drop-shadow(0 1px 1.5px rgba(0,0,0,0.1))","checklistHorizontalPadding":20,"checklistLauncherBgColor":"#22194d","checklistLauncherBorderRadius":30,"checklistLauncherFontWeight":500,"checklistLauncherHPadding":16,"checklistLauncherTextColor":"#ffffff","checklistLauncherVPadding":12,"checklistTaskCompletionDecoration":"STRIKE","checklistVerticalPadding":20,"checklistWidth":360,"closeColor":"rgb(173, 173, 173)","defaultEscapeView":false,"defaultNavigationButtons":false,"defaultNavigationButtonsStepCount":true,"defaultStepAppearance":"MODAL","dialogBgColor":"#ffffff","dialogBorderColor":"#cccccc","dialogBorderRadius":10,"dialogBorderWidth":2,"dialogFilter":"drop-shadow(0 3px 10.5px rgba(0,0,0,0.15)) drop-shadow(0 1px 1.5px rgba(0,0,0,0.1))","dialogFontFamily":"-apple-system,BlinkMacSystemFont,\"Segoe UI\",\"Roboto\",\"Oxygen\",\"Ubuntu\",\"Cantarell\",\"Fira Sans\",\"Droid Sans\",\"Helvetica Neue\",sans-serif","dialogFontSize":16,"dialogFontUrl":"","dialogLineHeight":24,"dialogLinkColor":"#1890ff","dialogLinkHoverColor":"#1890ff","dialogNavigationStepCountOpacity":40,"dialogPaddingHorizontal":40,"dialogPaddingVertical":40,"dialogProgressBarVisible":true,"dialogTextColor":"#222","focusRingColor":"#1B328D","focusRingWidth":4,"formFieldBorderRadius":4,"formFullWidthSubmitButton":false,"id":"cm5nx114l000603jxa8uvdub5","modalWidth":600,"primaryColor":"#22194d","progressBarBackgroundColor":"#EDEDED","progressBarColor":"#22194d","progressBarHeight":8,"swipeFooterBackgroundColor":"#191D30","swipeMobileBadgeOpacity":1,"swipeStepBackgroundColor":"#FAFAFA","swipeStepDescriptionColor":"#4b5563","swipeStepImageFocusDescriptionAlign":"CENTER","swipeStepImageFocusShowShadow":true,"swipeStepImageFocusTitleAlign":"CENTER","swipeStepTitleColor":"#000000","tooltipPointerSize":10,"tooltipWidth":300,"tooltipWidthLarge":400,"tooltipWidthSmall":200,"watermarkOpacity":80}},"themeId":"cm5nx114l000703jx7k3rfg64"},"type":"FLOW"},"flows":[{"id":"cm5x5wcxt000203mget5u8brs","name":"Axiom in 5 minutes","published":{"beaconHotkeyToggle":false,"completeBtn":{"actions":[{"addTrackingParams":true,"id":"complete-btn","type":"NAVIGATE","url":""}],"appearance":"PRIMARY","id":"complete-default","text":"Complete"},"escapeView":null,"hasNavigationBtns":false,"hasNavigationCompleteBtn":false,"hasStepCount":true,"id":"cm5x5wcxt000303mg2fuz4m2d","keyboardNavigation":true,"onExit":[],"schemaVersion":1,"steps":[{"appearance":"MODAL","backBtn":null,"backdropStyle":"HEAVY","buttons":[{"actions":[{"id":"cm5x6b1cw00043b6v5lido34f","type":"NEXT_STEP"}],"appearance":"PRIMARY","id":"cm5x6b1cw00033b6vaq18yed3","text":"Start exploring"}],"capture":{"webCapture":{"collectionId":"cm5x5flxu00023b6tterwrpq8","createdAt":"2025-01-15T00:36:01.373Z","editVersion":{"id":"cm5x683pw008l03l438v1gxvt","nodeKey":"nk_cm5x681xx00043b6xoy2o718q","webCaptureDataId":"cm5x681xx00053b6xqb5afrp0","webCaptureId":"cm5x681xx00053b6xqb5afrp0","webCaptureVersion":{"createdAt":"2025-01-15T00:36:01.373Z","creatorId":"cm5nx0jo1001rhmke3kqe93qn","id":"cm5x683pw008l03l438v1gxvt","nodeKey":"nk_cm5x681xx00043b6xoy2o718q","recordDataId":"cm5x681xx00053b6xqb5afrp0","recordId":"cm5x681xx00053b6xqb5afrp0"},"webCaptureVersionId":"cm5x683pw008l03l438v1gxvt"},"id":"cm5x681xx00053b6xqb5afrp0","name":"Getting Started","originalUrl":"https://app.axiom.co/axiom-play-qf1k","screenshot":"https://c.navattic.com/nv_static/nk_cm5x681xx00043b6xoy2o718q","updatedAt":"2025-01-15T00:36:11.353Z"}},"content":"{\"blocks\":[{\"key\":\"cbr45\",\"text\":\"Wel ``` -------------------------------- ### Installing next-axiom Library (Shell) Source: https://axiom.co/docs/send-data/nextjs Installs the `next-axiom` package from npm into the project dependencies. This command is required to use the library for sending data to Axiom from a Next.js application. ```sh npm install --save next-axiom ``` -------------------------------- ### Using indexof in Kusto Source: https://axiom.co/docs/apl/scalar-functions/string-functions Example demonstrating the `indexof` function to find the position of a substring within a string, specifying start index, length, and occurrence number. Compares the result to '-1'. ```kusto indexof( body, ['id'], 2, 1, number ) == "-1" ``` -------------------------------- ### Check Axiom CLI Version and Help Source: https://axiom.co/docs/reference/cli Executes the `axiom` command without arguments. This typically displays the CLI version and basic usage information, or initiates the login process if not configured. ```bash axiom ```