How to Use the APM Utility and CLI Commands
Access APM Utility Commands
SUMMARY After you've installed the Address Pool Manager (APM) application, you can perform the following administration functions.
You can use the APM utility script (apm
) to administer the application
and to access the CLI that you use to configure the address management functions. The
Juniper APM installation places the utility script in /var/local/apm
and creates a symbolic link to the script in /usr/local/bin/apm.
You can use the apm
utility script (which uses the Kubernetes
kubectl
utility commands) to do the following:
- Create and delete objects.
- Provide log access.
- Conduct interactive sessions with pod containers.
- Display the status of the APM objects.
Using the apm
utility script simplifies many of your administrative
duties. The script performs the tasks you need to manage APM, while masking the complexity
of the kubectl
command.
Table 1 lists the commands that you can invoke with the apm
utility script and
describes the action that occurs. Many of the individual commands have options that you
can specify.
Name |
Action |
---|---|
|
Access the CLI that you can use to configure APM features and to monitor the current status for managed BNGs. |
|
Connect to the APM database CLI. |
|
Restart one or more specified services. To run this command, you need sudo root privileges. Note:
Introduced in Release 3.1.0. |
|
Display APM logs. |
svc-logs |
Display APM persistent logs. Note:
Introduced in Release 3.1.0 |
|
Display the Kubernetes objects authored by APM that are necessary for orchestrating the APM pods. |
|
Set up the APM application as part of the installation process. To run this command, you need sudo root privileges. |
|
Start a specific APM service or all APM services. |
|
Display the current status of the APM services. |
|
Stop all APM services. |
|
Connect to a running APM service. |
|
Remove the APM application from the local system. To run this command, you need sudo root privileges. |
|
Display the version number of the installed APM application. |
|
Upgrade an APM service. To run this command, you need
sudo root privileges. Note:
Introduced in Release 3.1.0 |
Use the following general syntax to issue a command:
-
For a short option:
$ apm command-name -option
-
For a long option:
$ apm command-name ––option
To display a list of available commands with a brief description, use either the
h
or help
option:
$ apm -h
$ apm -help
To display the options for a specific command:
$ apm command-name -h
Start or Stop APM Services
Use the apm
utility script to start or stop all APM services. The
services start in order of dependency. Essential services (db and cmgd) start first,
followed by the other services. The services stop in reverse order of dependency.
-
To start all APM services:
$ apm start
Note:We recommend that you use the
apm start ––services
option to start individual services or a set of services only for troubleshooting under the guidance of a Juniper Networks support representative.Note:By default, APM starts from factory defaults. The configuration is reset to its initial state, any persistent state database (DB) is cleared, and any persistent logs are cleared. In APM Release 3.1.0, after the initial setup, you can use
apm start –-retain
to retain its previous state. -
To stop all APM services:
$ apm stop Stopping prov-man service... ok Stopping addr-man service... ok Stopping ent-man service... ok Stopping cfg-man service... ok Stopping dbHaMon service... ok Stopping log-man service... ok Stopping db service... ok Stopping cmgd service... ok Stopping apm-fluentd service... ok Awaiting service termination......................................... (9/9) APM services have been terminated
Check the Status of APM Services
Use the apm status
utility script to check the status of each APM
service (functional component) listed in Table 2. The status shows whether a service is running, has exited, or has not started. It also
displays the service name on the Kubernetes pod. You can compare uptime for the services
to quickly see whether any service has been restarted.
Service |
Service Name on the Pod |
---|---|
addr-man—Address manager |
jnpr-apm-addrman |
cfg-man—Configuration manager |
jnpr-apm-cfgman |
cmgd—CLI management |
jnpr-apm-cmgd |
db—Redis (Remote Dictionary Server), which provides the persistent database structure. |
jnpr-apm-redis |
dbHaMon—Redis sentinel that monitors and detects failures in the primary instance and elects a worker instance to serve as the new primary instance. |
jnpr-apm-redis-sentinels |
ent-man—Entity manager |
jnpr-apm-entman |
prov-man—Provisioning manager |
jnpr-apm-provman |
apm-fluentd—A set of pods that collect microservice |
jnpr-apm-fluentd |
log-man—Use this helper pod to collate, filter, and display logs that have been archived in persistent files. | jnpr-apm-logman Note:
Introduced in Release 3.1.0 |
To check the status:
For example:
$ apm status SERVICE STATE RESTARTS UP TIME NODE POD addr-man Running 0 0:19:02.297174 test-node-2 jnpr-apm-addrman-75db8795b5-6w4kl cfg-man Running 0 0:19:08.297316 test-node-1 jnpr-apm-cfgman-5cd4dfd869-4c9kf cmgd Running 0 0:19:51.297379 test-node-2 jnpr-apm-cmgd-6d7ffffbd8-2k7z6 ent-man Running 0 0:19:02.297435 test-node-1 jnpr-apm-entman-856469985b-q2ll5 apm-fluentd Running 0 0:19:52.297480 test-node-2 jnpr-apm-fluentd-bjks4 apm-fluentd Running 0 0:19:52.297521 test-node-1 jnpr-apm-fluentd-jwphb log-man Running 0 0:19:17.297567 test-node-2 jnpr-apm-logman-b788bdb9d-g5g5w prov-man Running 0 0:18:56.297607 test-node-1 jnpr-apm-provman-65b6f4974d-dz56s db-0 Running 0 0:20:14.297644 test-node-1 jnpr-apm-redis-0 db-1 Running 0 0:19:58.297694 test-node-2 jnpr-apm-redis-1 dbHaMon-0 Running 0 0:19:51.297737 test-node-1 jnpr-apm-redis-sentinels-0 dbHaMon-1 Running 0 0:19:40.297779 test-node-2 jnpr-apm-redis-sentinels-1 dbHaMon-2 Running 0 0:19:23.297816 test-node-1 jnpr-apm-redis-sentinels-2
Display Kubernetes Objects
Use the apm objects
utility script to display the Kubernetes objects
that are necessary for the orchestration of the APM pods. For example:
$ apm objects NAME TYPE STATUS DETAILS jnpr-apm-apmi External Service Present External IP(s):['10.9.160.15'], Cluster IP:10.103.47.17 jnpr-apm-cmgd-netconf External Service Present External IP(s):['10.9.160.15'], Cluster IP:10.97.198.5 jnpr-pv-apm-db-pvc Persistent Vol. Claim Bound Vol: jnpr-pv-apm-db, Acc(s): ['RWX'], Capy: 5Gi jnpr-pv-apm-log-pvc Persistent Vol. Claim Bound Vol: jnpr-pv-apm-log, Acc(s): ['RWX'], Capy: 1Gi jnpr-pv-apm-opcfg-pvc Persistent Vol. Claim Bound Vol: jnpr-pv-apm-opcfg, Acc(s): ['RWX'], Capy: 100Mi jnpr-apm-cfg Config Map Present Map:['juniper.conf', 'redis.conf'] jnpr-apm-log-cfg Config Map Present Map:['kubernetes.conf']
Display Logging
SUMMARY Use the
apm logs
utility script to display the logs of events that occur while
APM is running. Use the apm svc-logs
utility script to display file-based
logs collected and stored since the time APM is started. You enable file-based logging when
you set up APM.
Display APM Logging
Use the apm logs
utility script to display the logs of events
that occur while APM is running. The event logs include events such as those
shown in the following non-exhaustive list:
-
Pool-domain registration events
-
Address allocation failures
-
Network entity connection failures
-
Startup messages
-
Network entity resynchronization events
-
Pool and partition utilization threshold and depletion warnings
By default, APM sends logs to the standard output (stdout) of the service. The output displays the circular buffer of all services or of a specified service. You can also enable logging to follow the log output of the running services. Following the log output creates an open session that continuously streams the logs to stdout.
The APM logging functions mask the underlying complexities of the kubectl
log
command that is collecting the log information. You can still
use the kubectl log
command, but that is outside the scope of
this documentation.
You can use third-party applications to capture and redirect the stdout stream for the container. Refer to your third-party documentation for assistance. You can also configure Docker with different logging drivers to redirect stdout. Refer to your Docker documentation for assistance.
To display APM logs for all services:
$ apm logs
Use the apm logs ––services
option only when you are
troubleshooting under the guidance of a Juniper Networks support
representative.
To follow the logs for all services, specify the follow option
(-f
):
$ apm logs -f
To view logs from previous instances of the containers in a Kubernetes pod,
specify the previous container option (-p
):
$ apm logs -p
You can use standard Ubuntu conventions to redirect the logs to a file or to the terminal and to a file. Refer to the Ubuntu documentation for more information, but you can use the following examples as a starting point:
-
Redirect all logs to only a file.
$ apm logs > file-path
-
Redirect all logs to both the screen and to a file.
$ apm logs | tee file-path
By default, the utility command reports logs of all severity levels.
You can limit
the number of logs that are reported by setting a severity level when you start
APM services. Include the --log-level
option when you start
services to specify the minimum severity level of logs that are reported when
you also
use
the logs
command. Logs are reported for the specified level and
all levels that are more severe. The default level is debug
,
which is the lowest severity level. This means that by default logs are reported
for all levels.
When you set a severity level, it applies to all services.
-
To set the severity level for all services:
$ apm start ––log-level severity-level
Use the ––services
option only for troubleshooting under the
guidance of a Juniper Networks support representative.
You can specify any of the following severity levels, in order of increasing severity:
Severity Level | Description |
---|---|
debug |
Detailed information that is typically of interest only when you are trying to diagnose a problem. These logs are often very frequent. |
info |
Events or non-error conditions of interest. Logs at this level provide confirmation that everything is working as expected. These logs are generally not very frequent. |
warning |
Indicates that something unexpected happened or that some problem might occur in the near future. A simple example of the latter is the disk space low warning that indicates that you might run out of disk space soon. In either case, the software is still working as expected, but you might want to monitor it more closely. These logs are generally not very frequent. |
error |
Indicates that a more serious problem has prevented the software from performing some function, but the software has handled the problem as gracefully as possible to continue functioning. |
critical |
A serious error that indicates that the program itself might be unable to continue running. |
You can use the --logset
option to display logs either for only
APM services or for only prebuilt services. If you do not use this option, then
only the APM services logs are displayed.
To display logs for only APM services:
$ apm logs ––logset apm $ apm logs
To display logs for prebuilt services:
$ apm logs ––logset apm-infra
Prebuilt services are services borrowed from other sources to provide infrastructure functions for APM. These sources include cMGD, haproxy, redis, and redis-sentinel. For example, redis provides database and messaging services, cMGD provides a configuration/CLI service, and so on.
Display APM SVC Logging
Use the apm svc-logs
utility script (in APM Release 3.1.0) to
display file-based log output. You can enable file-based logging when you start
APM. If you select file-based logging during APM setup, APM displays logs from
the file regardless of the running state of APM. Collected logs are rotated such
that the capacity limit of the persistent volume is not exceeded. If you don't
select file-based logging during setup, the apm-svc-logs
utility displays the message File-based logging is not
enabled
.
To display SVC logs:
apm svc-logs [--services SERVICES [SERVICES]] [–-since <SINCE> | --tail | --head] [--entries <entries>] [--no-color]
By default, the utility command reports service logs of all types.
To select logs for a specific service, use the –- services
option:
apm svc-logs [--services SERVICES [services]
The –-services
argument specifies the set of APM microservices
to filter on. You can specify any of the following services:
cfg-man
prov-man
ent-man
addr-man
To limit the number of logs displayed, you can specify the filter to limit the start of the output:
$ apm svc-logs --since SINCE | --tail | --head
Where:
-
--since
SINCE—The--since
option specifies the timestamp in the YYYY-mm-dd-hh:mm:ss format to begin displaying log entries at or after the provided timestamp value till the end of the log is reached. -
--tail
—Display log entries from the end of the log (default is 100 entries). -
--head
—Display log entries from the beginning of the log (default is 100 entries).
To specify the number of entries to override the number of default entries displayed:
$ apm svc-logs --entries entries
To specify the no-color
option to disable colored-text output
(used to distinguish logs from different microservices):
$ apm svc-logs --no color
Determine the APM Version
Use the apm version
utility script to determine the version number of
the installed APM release.
To display the release version:
$ apm version
To display the version information for APM and for each service:
$ apm version ––detail
Use the -j
option to render the version information in JavaScript Object
Notation (JSON) format.
Uninstall and Remove APM
Use the apm
utility script to uninstall the APM configuration. The
uninstall
command reverts the actions you performed when setting up
APM. Use this command to return APM to the state it was in immediately after you installed
the application but before you did any setup configuration.
To uninstall APM:
$ sudo apm uninstall
After you uninstall APM, we recommend that you use the Debian uninstall procedure to remove the entire package.
$ sudo apt remove apm
How to Access APM Configuration and Operational Commands
- Access the APM CLI
- Access and Use CLI Configuration Statements
- Access and Use CLI Operational Commands
Access the APM CLI
To access the CLI prompt, enter the following apm
utility script
command:
$ apm cli root@jnpr-apm-cmgd>
Enter a question mark to see the available top-level CLI commands. This list of commands is a subset of the Junos OS top-level commands.
root@jnpr-apm-cmgd> ? Possible completions: clear Clear information in the system configure Manipulate software configuration information help Provide help information monitor Show real-time debugging information op Invoke an operation script quit Exit the management session request Make system-level requests set Set CLI properties, date/time, craft interface message show Show system information start Start shell
For an overview of Junos OS CLI basics, see Day One: Exploring the Junos CLI. For more detailed information, see the CLI User Guide.
Access and Use CLI Configuration Statements
Access and Use CLI Operational Commands
To monitor APM, view APM configuration and statistics, or run certain operations manually: