Activity Tracker hosted event search CLI
The IBM Cloud® command-line interface (CLI) provides extra capabilities for service offerings. This information describes how you can use the CLI to list and export information for IBM Cloud Activity Tracker service instances for an account.
As of 28 March 2024 the IBM Log Analysis and IBM Cloud Activity Tracker services are deprecated and will no longer be supported as of 30 March 2025. Customers will need to migrate to IBM Cloud Logs, which replaces these two services, prior to 30 March 2025. For information about IBM Cloud Logs, see the IBM Cloud Logs documentation.
This information applies only if you use an IBM Cloud® Activity Tracker hosted event search offering.
Prerequisites
-
Install the IBM Cloud CLI.
-
Install the CLI by running the following command:
ibmcloud plugin install logging
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
.
ibmcloud auditing service-instances
Use this command to list the service instances for IBM Cloud Activity Tracker.
ibmcloud logging service-instances [OPTIONS]
Command options
--service-name <NAME>
|--sn <NAME>
-
Name of the service.
--region <NAME>
|-r <NAME>
-
Name of the region, for example,
us-south
oreu-gb
. If not specified, the region logged into or targeted will be used. --all-regions
-
Services hosted across all regions.
-g <GROUP>
-
Resource Group associated with the hosted service.
--all-resource-groups
-
Services hosted across all resource groups.
--quiet
|-q
-
Supresses verbose output.
--output <TYPE>
-
A comma-separated list of output preferences enclosed in double-quotes ("). If only a single preference is specified, the double-quotes can be omitted. Supported options are
WIDE
andJSON
.If
JSON
is specified, output will be returned in JSON format. IfJSON
is not specified, output will be returned in a tabular format.WIDE
returns additional details in the output. --help
|-h
-
List options available for the command.
Examples
The following are examples using the ibmcloud logging service-instances
command.
List all auditing service instances.
ibmcloud logging service-instances
List all instances that are in the test-rg
resource group.
ibmcloud logging service-instances -g test-rg
List all instances and include additional details, such as ID, GUID, and Resource ID.
ibmcloud logging service-instances --output wide
List all instances and include only the minimal details of Name, Region and State.
ibmcloud logging service-instances --quiet
List all instances for the us-south
region.
ibmcloud logging service-instances --region us-south
List all instances in the us-south
region and returns the output in JSON format.
ibmcloud logging service-instances --region us-south --output json
ibmcloud logging export
Use this command to export events. Options are provided to filter the exported events. Exported information is presented as a response to the command and can optionally be accessed by a link sent to an email address provided on the command.
ibmcloud logging export --service-key <SERVICE_KEY> [OPTIONS]
Command options
--service-key <SERVICE_KEY>
|-s <SERVICE_KEY>
- (REQUIRED) Service key for the instance.
--region <REGION>
|-r <REGION>
- Name of the region, for example,
us-south
oreu-gb
. If not specified, the region logged into or targeted will be used. --hosts <HOST_NAMES>
|--ho <HOST_NAMES>
- A comma-separated list of host names enclosed in double-quotes ("). If only a single host name is specified, the double-quotes can be omitted. Log entries for the specified host names will be returned.
--apps <APP_NAMES>
|-a <APP_NAMES>
- A comma-separated list of app names enclosed in double-quotes ("). If only a single app name is specified, the double-quotes can be omitted. Log entries for the specified apps will be returned.
--levels <LOG_LEVELS>
|-l <LOG_LEVELS>
- A comma-separated list of log level values enclosed in double-quotes ("). If only a single level is specified, the double-quotes can be omitted. Log entries with the specified level will be returned. Depending on your environment log levels can include: CRITICAL, DEBUG, EMERGENCY, ERROR, FATAL, INFO, SEVERE, TRACE, WARN, or ALERT.
--number <NUMBER>
|-n <NUMBER>
- The total number of log entries to be exported.
--from <TIME>
- The starting time to be used for log entries. No log entries early than this time will be returned.
<TIME>
is specified as a UNIX timestamp in seconds or milliseconds. --to <TIME>
- The ending time to be used for log entries. No log entries after than this time will be returned.
<TIME>
is specified as a UNIX timestamp in seconds or milliseconds. --output <TYPE>
- Type of output produced. If
JSON
is specified, output will be returned in JSON format. If not specified, output will be returned in tabular format. --query <STRING>
|-q <STRING>
- A value to be searched for within the log. All log entries containing the specified
<STRING>
will be returned. --prefer <VALUE>
|-p <VALUE>
- The log lines you want to export. Valid values are
HEAD
andTAIL
.HEAD
specifies the log lines will be exported from the earliest entry to the most current entry.TAIL
specifies the log lines will be exported in reverse order from the most current entry to the earliest entry. If not specified, the default isTAIL
. --email <ADDRESS>
|-e <ADDRESS>
- If specified, an email with a link to the export information will be sent to the specified email
<ADDRESS>
. The recipient can use that link to download the exported information. --email-subject <SUBJECT>
|--es <SUBJECT>
- Use with
--email
to specify a subject line to be included in the email that is sent. --help
|-h
- List options available for the command.
Examples
The following are examples using the ibmcloud logging export
command.
Export all logs for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY>
Export log entries for the provided service key occurring during the specified time range. Time stamps need to be in UNIX format. For example: 1614228407550
.
ibmcloud logging export --service-key <SERVICE_KEY> --to <END_TIME> --from <START_TIME>
Export INFO
and ERROR
level log entries for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --levels "INFO,ERROR"
Export log entries for the metric-server
and myapp
apps for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --apps "metrics-server,myapp"
Export log entries for the test-hostname
and cloudantnosqldb
hosts for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --hosts "test-hostname,cloudantnosqldb"
Export log entries for the eu-gb
region for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --region eu-gb
Export log entries containing the string "new line" for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --query "new line"
Export log entries containing the string "new line" in the first log lines (head
) for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --query "new line" --prefer head
Export log entries in JSON format for the myapp
app for the provided service key.
ibmcloud logging export --service-key <SERVICE_KEY> --apps myapp --output json
Send an email with a downloadable link to myemail@mycompany.com
with the subject "Emailing myapp logs". In this example the link will let myemail@mycompany.com
see the list of all log entries for the myapp
app for the provided service key at the time the command was run.
ibmcloud logging export --service-key <SERVICE_KEY> --apps myapp --email myemail@mycompany.com --email-subject "Emailing myapp logs"