Skip to content

Commit 8500d36

Browse files
jordanpadamsclaude
andcommitted
Add comprehensive weblog upload documentation
Adds a dedicated "Uploading Weblogs" section to the usage docs covering prerequisites, gzip compression, required arguments, S3 path construction, subdirectory organization best practices, dry-run verification, and common error remediation. Fixes #366. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d15b3fd commit 8500d36

1 file changed

Lines changed: 164 additions & 2 deletions

File tree

docs/source/usage/index.rst

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ in AWS would resolve to ``bundle/file.xml``.
7878
The ``--weblogs LOG_TYPE`` argument can be used to indicate that weblog files are being uploaded.
7979
The type of log files (e.g. ``apache``, ``nginx``, etc.) should be specified as the
8080
``LOG_TYPE`` argument. When this flag is provided, the client will automatically adjust
81-
the "trimmed" path for each ingested file to replace the specified path prefix with ``weblog/``,
82-
ensuring that all weblog files are routed to a specific S3 bucket used for web analytics.
81+
the "trimmed" path for each ingested file to replace the specified path prefix with
82+
``weblogs/<node>-<log_type>/``, ensuring that all weblog files are routed to the S3
83+
bucket used for web analytics.
8384
Because of this, the ``--prefix`` argument must be provided when using the ``--weblogs`` argument.
8485

8586
.. warning::
@@ -96,6 +97,8 @@ Because of this, the ``--prefix`` argument must be provided when using the ``--w
9697
1. Compress all files with gzip before uploading, or
9798
2. Use the ``--exclude`` argument to filter out non-gzipped files (e.g., ``--exclude "*.txt"``)
9899

100+
See the `Uploading Weblogs`_ section below for a complete walkthrough.
101+
99102
The ``pds-ingress-client`` by default utilizes all available CPUs on the
100103
local machine to perform parallelized ingress requests to the ingress service. The exact
101104
number of threads can be controlled via the ``--num-threads`` argument.
@@ -257,6 +260,165 @@ Files that still fail to upload during this final attempt are recorded in the fi
257260

258261
Should persistent failures like this occur, they should be communicated to the PDS Operations team for investigation.
259262

263+
Uploading Weblogs
264+
-----------------
265+
266+
PDS nodes can upload web server log files directly to the PDS web analytics S3 bucket using the
267+
``--weblogs`` flag. This section walks through the full process.
268+
269+
Prerequisites
270+
^^^^^^^^^^^^^
271+
272+
Before uploading weblogs, ensure the following:
273+
274+
1. **Your DUM client is installed and configured** — see the installation_ instructions for
275+
creating your INI config file.
276+
2. **Log files are gzip-compressed** — every file must have a ``.gz`` extension. The client
277+
will reject the entire upload if any non-gzipped file is detected.
278+
3. **You know your node ID** — one of ``atm``, ``eng``, ``geo``, ``img``, ``naif``, ``ppi``,
279+
``rs``, ``rms``, ``sbn``.
280+
281+
Compressing Log Files
282+
^^^^^^^^^^^^^^^^^^^^^
283+
284+
If your log files are not already compressed, gzip them before uploading::
285+
286+
$ gzip /path/to/logs/access.log
287+
$ gzip /path/to/logs/*.log
288+
289+
This produces files with a ``.gz`` extension (e.g., ``access.log.gz``).
290+
291+
Uploading
292+
^^^^^^^^^
293+
294+
Use the ``--weblogs LOG_TYPE`` argument along with ``--prefix`` to upload weblogs. ``LOG_TYPE``
295+
identifies the type of web server generating the logs (e.g., ``apache``, ``nginx``, ``iis``,
296+
``tomcat``). The value is case-insensitive and becomes part of the S3 destination path.
297+
298+
**Required arguments for weblog uploads:**
299+
300+
- ``--weblogs LOG_TYPE`` — designates the upload as weblogs and specifies the log type
301+
- ``--prefix PATH`` — the local path prefix to strip from uploaded file paths
302+
- ``--node NODE_ID`` — your PDS node identifier
303+
304+
**Example:**
305+
306+
Suppose your compressed log files are stored under ``/data/weblogs/`` and you want to upload
307+
them on behalf of the SBN node using Apache-format logs::
308+
309+
$ pds-ingress-client \
310+
-c /path/to/config.ini \
311+
--node sbn \
312+
--weblogs apache \
313+
--prefix /data/weblogs \
314+
-- /data/weblogs/
315+
316+
How the Destination Path Is Constructed
317+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
318+
319+
When ``--weblogs`` is specified, the client replaces the ``--prefix`` value in each file path
320+
with ``weblogs/<node>-<log_type>/``. For example, with ``--node sbn``, ``--weblogs apache``,
321+
and ``--prefix /data/weblogs``, a local file at:
322+
323+
.. code-block::
324+
325+
/data/weblogs/2025/01/access.log.gz
326+
327+
is uploaded to S3 as:
328+
329+
.. code-block::
330+
331+
weblogs/sbn-apache/2025/01/access.log.gz
332+
333+
Organizing Logs with Subdirectories
334+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
335+
336+
.. important::
337+
338+
The directory structure **below** the ``--prefix`` path is preserved in S3. This means
339+
that if all your log files sit directly in ``--prefix`` with no subdirectories, they will
340+
all land in a single flat S3 directory. For easier downstream grouping by application,
341+
domain, or server, **organize your logs into subdirectories on disk before uploading**.
342+
343+
For example, suppose you host multiple web applications and collect logs from each. Rather
344+
than keeping all logs flat under ``/data/weblogs/``::
345+
346+
/data/weblogs/
347+
├── pds.nasa.gov_access.log.gz
348+
├── pds.nasa.gov_error.log.gz
349+
├── sbn.psi.edu_access.log.gz
350+
└── sbn.psi.edu_error.log.gz
351+
352+
organize them into subdirectories by application or domain::
353+
354+
/data/weblogs/
355+
├── pds.nasa.gov/
356+
│ ├── access.log.gz
357+
│ └── error.log.gz
358+
└── sbn.psi.edu/
359+
├── access.log.gz
360+
└── error.log.gz
361+
362+
With ``--prefix /data/weblogs``, the second layout uploads to S3 as::
363+
364+
weblogs/sbn-apache/pds.nasa.gov/access.log.gz
365+
weblogs/sbn-apache/pds.nasa.gov/error.log.gz
366+
weblogs/sbn-apache/sbn.psi.edu/access.log.gz
367+
weblogs/sbn-apache/sbn.psi.edu/error.log.gz
368+
369+
This makes it straightforward to query or process logs for a specific application without
370+
filtering a large flat directory.
371+
372+
You can also upload logs for a single application at a time by pointing DUM at a specific
373+
subdirectory and setting ``--prefix`` to its parent::
374+
375+
$ pds-ingress-client \
376+
-c /path/to/config.ini \
377+
--node sbn \
378+
--weblogs apache \
379+
--prefix /data/weblogs \
380+
-- /data/weblogs/pds.nasa.gov/
381+
382+
This uploads only ``pds.nasa.gov/`` logs, preserving the subdirectory name in the S3 path.
383+
384+
Verifying Before Upload
385+
^^^^^^^^^^^^^^^^^^^^^^^
386+
387+
Use ``--dry-run`` to preview which files will be uploaded and confirm the correct set is
388+
selected, without actually submitting anything::
389+
390+
$ pds-ingress-client \
391+
-c /path/to/config.ini \
392+
--node sbn \
393+
--weblogs apache \
394+
--prefix /data/weblogs \
395+
--dry-run \
396+
-- /data/weblogs/
397+
398+
Common Issues
399+
^^^^^^^^^^^^^
400+
401+
**Upload fails with "non-gzipped files" error**
402+
403+
The client checks every file before uploading begins. If any file lacks a ``.gz`` extension,
404+
you will see an error like::
405+
406+
ERROR: The following files are not gzipped (.gz):
407+
/data/weblogs/access.log
408+
ValueError: Weblog uploads require gzipped files. Found 1 non-gzipped file(s). ...
409+
410+
Compress the listed files with ``gzip`` and retry, or use ``--exclude`` to skip them::
411+
412+
$ pds-ingress-client ... --exclude "*.log" -- /data/weblogs/
413+
414+
**Upload fails with "--prefix must also be provided" error**
415+
416+
The ``--prefix`` argument is required when ``--weblogs`` is used::
417+
418+
ValueError: When --weblogs is specified, --prefix must also be provided.
419+
420+
Add ``--prefix /your/local/log/directory`` to the command.
421+
260422
.. References:
261423
.. _backoff: https://pypi.org/project/backoff/
262424
.. _installation: ../installation/index.html

0 commit comments

Comments
 (0)