github.com/thanos-io/thanos@v0.32.5/docs/logging.md (about)

     1  # Logging
     2  
     3  Thanos supports request logging via flags.
     4  
     5  Components are either configured using `--request.logging-config-file` to reference to the configuration file or `--request.logging-config` to provide configuration as YAML directly.
     6  
     7  ## Configuration
     8  
     9  Configuration can be supplied globally, which applies to both `grpc` and `http`. Alternatively `http` and/or `grpc` can be configured independently.
    10  
    11  ### Options
    12  
    13  Valid `level` for `options` should be one of `INFO`, `WARNING`, `ERROR` or `DEBUG`.
    14  
    15  ```yaml
    16  options:
    17    level: ERROR
    18  ```
    19  
    20  The request logging is configurable per phase via the `decision`.
    21  
    22  Valid decision combinations are as follows:
    23  
    24  * Log details only when the request completes - Log level is determined by the status code from the response.
    25  
    26  ```yaml
    27  options:
    28    decision:
    29      log_start: false
    30      log_end: true
    31  ```
    32  
    33  * Log details prior to the request and when the request completes - Pre request log is made at `debug` level.
    34  
    35  ```yaml
    36  options:
    37    decision:
    38      log_start: true
    39      log_end: true
    40  ```
    41  
    42  ### HTTP
    43  
    44  Specifying an `http` block enables request logging for each endpoint.
    45  
    46  ```yaml
    47  http:
    48    options:
    49      level: DEBUG
    50      decision:
    51        log_start: true
    52        log_end: true
    53  ```
    54  
    55  The log level of the "post request" log is determined by the status code in the response.
    56  
    57  The following mappings apply:
    58  * `200 <= status code < 500` = `debug`
    59  * `status code > 500` = `error`
    60  
    61  Optionally, additional configuration can be supplied via the `config` block to create an allowlist of endpoint and port combinations. Note that this feature requires an exact match if enabled.
    62  
    63  ```yaml
    64  http:
    65    config:
    66      - path: /api/v1/query
    67        port: 10904
    68      - path: /api/v1/app_range/metrics
    69        port: 3456
    70  ```
    71  
    72  ### gRPC
    73  
    74  Specifying a `grpc` block enables request logging for each service and method name combination.
    75  
    76  ```yaml
    77  grpc:
    78    options:
    79      level: DEBUG
    80      decision:
    81        log_start: true
    82        log_end: true
    83  ```
    84  
    85  The log level of the "post request" log is determined by the [code](https://grpc.github.io/grpc/core/md_doc_statuscodes.html) in the response.
    86  
    87  The following mappings apply:
    88  * Codes `2, 12, 13 ,15` = `error`
    89  * All other codes = `debug`
    90  
    91  Optionally, additional configuration can be supplied via the `config` block to create an allowlist of service and method combinations. Note that this feature requires an exact match if enabled.
    92  
    93  ```yaml
    94  grpc:
    95    config:
    96      - service: thanos.Store
    97        method: Info
    98  ```
    99  
   100  ## How to use `config` flags?
   101  
   102  The following example shows how the logging config can be supplied to the `sidecar` component:
   103  
   104  ```yaml
   105        - args:
   106          - sidecar
   107          - |
   108            --objstore.config=type: GCS
   109            config:
   110              bucket: <bucket>
   111          - --prometheus.url=http://localhost:9090
   112          - |
   113            --request.logging-config=http:
   114              config:
   115                - path: /api/v1/query
   116                  port: 10904
   117              options:
   118                level: DEBUG
   119                decision:
   120                  log_start: true
   121                  log_end: true
   122            grpc:
   123              config:
   124                - service: thanos.Store
   125                  method: Info
   126              options:
   127                level: ERROR
   128                decision:
   129                  log_start: false
   130                  log_end: true
   131          - --tsdb.path=/prometheus-data
   132  ```
   133  
   134  Note that in the above example, logs will be emitted at `debug` level. These logs will be filtered unless the flag `--log.level=debug` is set.