Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBM-1226 Documented custom log path configuration #235

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/manage/logpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Output pbm-agent logs to a file

Check warning on line 1 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L1

[Google.Headings] 'Output pbm-agent logs to a file' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'Output pbm-agent logs to a file' should use sentence-style capitalization.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 1, "column": 3}}}, "severity": "WARNING"}

!!! admonition "Version added: [2.8.0](../release-notes/2.8.0.md)"


By default, each `pbm-agent` writes its logs to the following paths:

* the `admin.pbmLogs` PBM Control collection which serves as the centralized logging storage
* `STDERR` stream on the each host where the agent is running

Starting with version 2.8.0, you can configure every `pbm-agent` to output logging information to a file at a custom path. This enhancement enables you to achieve the following:

* optimize system logging as the `pbm-agent` logs are stored in a separate file and don't mix with other system logs

Check notice on line 13 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L13

[Google.Passive] In general, use active voice instead of passive voice ('are stored').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are stored').", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 13, "column": 51}}}, "severity": "INFO"}
* introduce the log rotation policy for the effective usage of the storage space
* simplify the log collection process for further analysis
* comply with the logging and auditing requirements by storing logs in a secure location for the required period

You can define a logging configuration either via the command line flags or via environment variables when you start a `pbm-agent`. The options are:

| Environment variable | Command line flag | Description |
|----------------------|-------------------|-------------|
| `LOG_PATH` | `--log-path` | The path to the log file. The file is created if it doesn't exist. The default value is `/dev/stderr` which means that the logs are written to the standard error output. |

Check notice on line 22 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L22

[Google.Passive] In general, use active voice instead of passive voice ('is created').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is created').", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 22, "column": 66}}}, "severity": "INFO"}

Check notice on line 22 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L22

[Google.Passive] In general, use active voice instead of passive voice ('are written').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are written').", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 22, "column": 159}}}, "severity": "INFO"}
| `LOG_LEVEL` | `--log-level` | The log severity level. Supported levels are (from low to high): D - Debug (default), I - Info, W - Warning, E - Error, F - Fatal.<br><br> The output includes both the specified severity level and all higher ones |

Check notice on line 23 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L23

[Google.Parens] Use parentheses judiciously.
Raw output
{"message": "[Google.Parens] Use parentheses judiciously.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 23, "column": 78}}}, "severity": "INFO"}

Check warning on line 23 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L23

[Google.FirstPerson] Avoid first-person pronouns such as ' I '.
Raw output
{"message": "[Google.FirstPerson] Avoid first-person pronouns such as ' I '.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 23, "column": 118}}}, "severity": "WARNING"}
| `LOG_JSON`| `--log-json` | Output log messages in JSON format. If undefined, logs are written in the default text format. |

Check notice on line 24 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L24

[Google.Passive] In general, use active voice instead of passive voice ('are written').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are written').", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 24, "column": 85}}}, "severity": "INFO"}

## Example

Start the `pbm-agent` on every node with the following command:

=== ":material-variable: Environment variables"

Check warning on line 30 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L30

[Google.Colons] ': E' should be in lowercase.
Raw output
{"message": "[Google.Colons] ': E' should be in lowercase.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 30, "column": 24}}}, "severity": "WARNING"}

```{.bash data-prompt="$"}
$ export LOG_PATH=/var/log/pbm-agent.log
$ export LOG_LEVEL=W
$ export LOG_JSON=1
$ pbm-agent
```

=== ":material-console: Command line"

Check warning on line 39 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L39

[Google.Colons] ': C' should be in lowercase.
Raw output
{"message": "[Google.Colons] ': C' should be in lowercase.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 39, "column": 23}}}, "severity": "WARNING"}

```{.bash data-prompt="$"}
$ pbm-agent --log-path=/var/log/pbm-agent.log --log-level=W --log-json
```

!!! note

Command line flags take precedence over environment variables.

If PBM cannot write to the specified file due to some error, it falls back to `STDERR` stream. And you can always retrieve the logging information using the `pbm logs` command.

Check notice on line 49 in docs/manage/logpath.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/manage/logpath.md#L49

[Google.Contractions] Use 'can't' instead of 'cannot'.
Raw output
{"message": "[Google.Contractions] Use 'can't' instead of 'cannot'.", "location": {"path": "docs/manage/logpath.md", "range": {"start": {"line": 49, "column": 8}}}, "severity": "INFO"}

This ability to output logs to a file at a custom path enhances log management, making it easier to monitor and audit PBM operations effectively, and facilitates regulatory compliance.
1 change: 1 addition & 0 deletions mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ nav:
- 'Overview': manage/overview.md
- 'PBM configuration via pipelines': 'manage/configure-remotely.md'
- 'Automate access to S3 buckets for PBM': 'manage/automate-s3-access.md'
- logpath.md
- 'Upgrade PBM': 'manage/upgrading.md'
- 'Remove PBM': 'manage/uninstalling.md'
- Architecture:
Expand Down
Loading