Working with the IBM Cloud Logs CLI

You can use the IBM® Cloud Logs command-line interface (CLI) to manage your IBM Cloud Logs instance.

Both ibmcloud cloud-logs and ibmcloud logs can be used to run IBM Cloud Logs CLI commands.

Use ibmcloud cloud-logs COMMAND --help for more information about a command.

Prerequisites

Installing the IBM Cloud Logs CLI Plugin

Install the IBM Cloud Logs CLI plug-in by running the following command:

ibmcloud plugin install logs

You're notified on the command line when updates to the IBM Cloud CLI and plug-ins are available. Be sure to keep your CLI up to date so that you can use the latest commands. You can view the current version of all installed plug-ins by running ibmcloud plugin list.

Setting the IBM Cloud Logs instance

To target the IBM Cloud Logs instance every time you run a CLI command, use one of the following options:

  • Option 1: Run the ibmcloud logs config set command to configure the service URL and persist the value in the terminal that you use to run the commands.

    ibmcloud logs config set service-url https://{API_endpoint}
    

    Global parameters can be stored in a persistent configuration so that you do not need to manually specify each time you run a command.

    You can manage configuration parameters with the ibmcloud logs config commands.

  • Option 2: Set the service endpoint in each command that you run.

    Export an environment variable with your IBM Cloud Logs service endpoint URL.

    export LOGS_URL=https://{API_endpoint}
    

    Add the --service-url to each command.

    ibmcloud logs --service-url $LOGS_URL
    

    Replace {API_endpoint} with the API endpoint that is specific to your instance. The API endpoint information can be copied from the service details page in the IBM Cloud Logs UI. For more information, see Service API endpoints.

Commands to manage alerts

The following table lists the commands that you can use to manage alerts:

IBM Cloud Logs V3 alert definition CLI commands
Command Description
alert-definition Get an alert definition by ID.
alert-definition-create Create an alert definition.
alert-definition-delete Delete an alert definition by ID.
alert-definition-update Update an alert definition by ID.
alert-definitions List alert definitions.

Commands to manage queries

The following table lists the command that you can use to manage queries:

IBM Cloud Logs query CLI commands
Command Description
query Run a query to search the logs.

The following table lists the commands that you can use to manage background queries:

IBM Cloud Logs background query (asynchronous archive query) CLI commands
Command Description
background-query-cancel, bgq-cancel Cancel a background query.
background-query-create, bgq-create Submit a background query to be processed asynchronously.
background-query-data, bgq-data Data of the background query to search the logs.
background-query-status, bgq-status Get the status of a background query.

Commands to manage data access rules

The following table lists the commands that you can use to manage data access rules:

IBM Cloud Logs data access rule CLI commands
Command Description
data-access-rule-create Create a data access rule.
data-access-rule-delete Delete a data access rule.
data-access-rule-update Update a data access rule.
data-access-rules Get a service instance's data access rules by ID.

Commands to manage data usage

The following table lists the commands that you can use to manage data usage:

IBM Cloud Logs data usage CLI commands
Command Description
data-usage Get the daily and detailed data usage.
data-usage-metrics-export-status Get the data usage metrics export status.
data-usage-metrics-export-status-update Update the data usage metrics export status.

Commands to manage enrichments

The following table lists the commands that you can use to manage enrichments:

IBM Cloud Logs enrichment CLI commands
Command Description
enrichment-create Create an enrichment.
enrichment-delete Delete enrichments.
enrichments List all enrichments.

Commands to manage streaming

The following table lists the commands that you can use to manage streaming:

IBM Cloud Logs Event Streams integration CLI commands
Command Description
event-stream-target-create Create an IBM Event Streams for IBM Cloud integration.
event-stream-target-delete Delete an Event Streams integration by ID.
event-stream-target-update Update an Event Streams integration.
event-stream-targets List all Event Streams integrations.

Commands to manage events2metrics

The following table lists the commands that you can use to manage events2metrics:

IBM Cloud Logs events to metrics CLI commands
Command Description
events2metrics, e2m Gets the events to metrics definitions by ID.
events2metrics-create, e2m-create Creates the events to metrics definitions.
events2metrics-delete, e2m-delete Deletes the events to metrics definitions by ID.
events2metrics-list, e2m-list Lists the events to metrics definitions.
events2metrics-update, e2m-update Updates the events to metrics definitions.

Commands to manage webhooks

The following table lists the commands that you can use to manage webhooks:

IBM Cloud Logs outbound integration CLI commands
Command Description
outgoing-webhook Gets an outbound integration by ID.
outgoing-webhook-create Create an outbound integration.
outgoing-webhook-delete Delete an outbound integration.
outgoing-webhook-update Update an outbound integration.
outgoing-webhooks List outbound integrations.

Commands to manage policies

The following table lists the commands that you can use to manage policies:

IBM Cloud Logs policy CLI commands
Command Description
policies Gets policies.
policy Gets policy by ID.
policy-create Creates a new policy.
policy-delete Deletes an existing policy.
policy-update Updates an existing policy.

Commands to manage rule groups

The following table lists the commands that you can use to manage rule groups:

IBM Cloud Logs rules CLI commands
Command Description
rule-group Gets a rule group by groupid.
rule-group-create Creates a rule group.
rule-group-delete Deletes a rule group by groupid.
rule-group-update Updates a rule group by groupid.
rule-groups Gets all rule groups.

Commands to manage views

The following table lists the commands that you can use to manage views:

IBM Cloud Logs view CLI commands
Command Description
view Gets a view by ID.
view-create Creates a new view.
view-delete Deletes a view by ID.
view-update Replaces an existing view.
views Lists all company public views.

Commands to manage view folders

The following table lists the commands that you can use to manage view folders:

IBM Cloud Logs view folder CLI commands
Command Description
view-folder Get view folder.
view-folder-create Create view folder.
view-folder-delete Deletes a view folder by ID.
view-folder-update Replaces an existing view folder.
view-folders List view's folders.

Commands to manage extensions

The following table lists the commands that you can use to manage extensions:

IBM Cloud Logs extensions CLI commands
Command Description
extensions Gets an extension by ID.
extension-deployment Get deplayment details by an extension.
extension-deployment-delete Delete deployment of an extension.
extension-deployment-managep Deploy or update deployment of an extension.
extensions Get list of extensions.