github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/outputs/nats.md (about)

     1  ---
     2  title: nats
     3  type: output
     4  status: stable
     5  categories: ["Services"]
     6  ---
     7  
     8  <!--
     9       THIS FILE IS AUTOGENERATED!
    10  
    11       To make changes please edit the contents of:
    12       lib/output/nats.go
    13  -->
    14  
    15  import Tabs from '@theme/Tabs';
    16  import TabItem from '@theme/TabItem';
    17  
    18  
    19  Publish to an NATS subject.
    20  
    21  
    22  <Tabs defaultValue="common" values={[
    23    { label: 'Common', value: 'common', },
    24    { label: 'Advanced', value: 'advanced', },
    25  ]}>
    26  
    27  <TabItem value="common">
    28  
    29  ```yaml
    30  # Common config fields, showing default values
    31  output:
    32    label: ""
    33    nats:
    34      urls:
    35        - nats://127.0.0.1:4222
    36      subject: benthos_messages
    37      headers: {}
    38      max_in_flight: 1
    39  ```
    40  
    41  </TabItem>
    42  <TabItem value="advanced">
    43  
    44  ```yaml
    45  # All config fields, showing default values
    46  output:
    47    label: ""
    48    nats:
    49      urls:
    50        - nats://127.0.0.1:4222
    51      subject: benthos_messages
    52      headers: {}
    53      max_in_flight: 1
    54      tls:
    55        enabled: false
    56        skip_cert_verify: false
    57        enable_renegotiation: false
    58        root_cas: ""
    59        root_cas_file: ""
    60        client_certs: []
    61      auth:
    62        nkey_file: ""
    63        user_credentials_file: ""
    64  ```
    65  
    66  </TabItem>
    67  </Tabs>
    68  
    69  This output will interpolate functions within the subject field, you
    70  can find a list of functions [here](/docs/configuration/interpolation#bloblang-queries).
    71  
    72  ### Authentication
    73  
    74  There are several components within Benthos which utilise NATS services. You will find that each of these components
    75  support optional advanced authentication parameters for [NKeys](https://docs.nats.io/nats-server/configuration/securing_nats/auth_intro/nkey_auth)
    76  and [User Credentials](https://docs.nats.io/developing-with-nats/security/creds).
    77  
    78  An in depth tutorial can be found [here](https://docs.nats.io/developing-with-nats/tutorials/jwt).
    79  
    80  #### NKey file
    81  
    82  The NATS server can use these NKeys in several ways for authentication. The simplest is for the server to be configured
    83  with a list of known public keys and for the clients to respond to the challenge by signing it with its private NKey
    84  configured in the `nkey_file` field.
    85  
    86  More details [here](https://docs.nats.io/developing-with-nats/security/nkey).
    87  
    88  #### User Credentials file
    89  
    90  NATS server supports decentralized authentication based on JSON Web Tokens (JWT). Clients need an [user JWT](https://docs.nats.io/nats-server/configuration/securing_nats/jwt#json-web-tokens)
    91  and a corresponding [NKey secret](https://docs.nats.io/developing-with-nats/security/nkey) when connecting to a server
    92  which is configured to use this authentication scheme.
    93  
    94  The `user_credentials_file` field should point to a file containing both the private key and the JWT and can be
    95  generated with the [nsc tool](https://docs.nats.io/nats-tools/nsc).
    96  
    97  More details [here](https://docs.nats.io/developing-with-nats/security/creds).
    98  
    99  ## Performance
   100  
   101  This output benefits from sending multiple messages in flight in parallel for
   102  improved performance. You can tune the max number of in flight messages with the
   103  field `max_in_flight`.
   104  
   105  ## Fields
   106  
   107  ### `urls`
   108  
   109  A list of URLs to connect to. If an item of the list contains commas it will be expanded into multiple URLs.
   110  
   111  
   112  Type: `array`  
   113  Default: `["nats://127.0.0.1:4222"]`  
   114  
   115  ```yaml
   116  # Examples
   117  
   118  urls:
   119    - nats://127.0.0.1:4222
   120  
   121  urls:
   122    - nats://username:password@127.0.0.1:4222
   123  ```
   124  
   125  ### `subject`
   126  
   127  The subject to publish to.
   128  This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries).
   129  
   130  
   131  Type: `string`  
   132  Default: `"benthos_messages"`  
   133  
   134  ### `headers`
   135  
   136  Explicit message headers to add to messages.
   137  This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries).
   138  
   139  
   140  Type: `object`  
   141  Default: `{}`  
   142  
   143  ```yaml
   144  # Examples
   145  
   146  headers:
   147    Content-Type: application/json
   148    Timestamp: ${!meta("Timestamp")}
   149  ```
   150  
   151  ### `max_in_flight`
   152  
   153  The maximum number of messages to have in flight at a given time. Increase this to improve throughput.
   154  
   155  
   156  Type: `int`  
   157  Default: `1`  
   158  
   159  ### `tls`
   160  
   161  Custom TLS settings can be used to override system defaults.
   162  
   163  
   164  Type: `object`  
   165  
   166  ### `tls.enabled`
   167  
   168  Whether custom TLS settings are enabled.
   169  
   170  
   171  Type: `bool`  
   172  Default: `false`  
   173  
   174  ### `tls.skip_cert_verify`
   175  
   176  Whether to skip server side certificate verification.
   177  
   178  
   179  Type: `bool`  
   180  Default: `false`  
   181  
   182  ### `tls.enable_renegotiation`
   183  
   184  Whether to allow the remote server to repeatedly request renegotiation. Enable this option if you're seeing the error message `local error: tls: no renegotiation`.
   185  
   186  
   187  Type: `bool`  
   188  Default: `false`  
   189  Requires version 3.45.0 or newer  
   190  
   191  ### `tls.root_cas`
   192  
   193  An optional root certificate authority to use. This is a string, representing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.
   194  
   195  
   196  Type: `string`  
   197  Default: `""`  
   198  
   199  ```yaml
   200  # Examples
   201  
   202  root_cas: |-
   203    -----BEGIN CERTIFICATE-----
   204    ...
   205    -----END CERTIFICATE-----
   206  ```
   207  
   208  ### `tls.root_cas_file`
   209  
   210  An optional path of a root certificate authority file to use. This is a file, often with a .pem extension, containing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.
   211  
   212  
   213  Type: `string`  
   214  Default: `""`  
   215  
   216  ```yaml
   217  # Examples
   218  
   219  root_cas_file: ./root_cas.pem
   220  ```
   221  
   222  ### `tls.client_certs`
   223  
   224  A list of client certificates to use. For each certificate either the fields `cert` and `key`, or `cert_file` and `key_file` should be specified, but not both.
   225  
   226  
   227  Type: `array`  
   228  Default: `[]`  
   229  
   230  ```yaml
   231  # Examples
   232  
   233  client_certs:
   234    - cert: foo
   235      key: bar
   236  
   237  client_certs:
   238    - cert_file: ./example.pem
   239      key_file: ./example.key
   240  ```
   241  
   242  ### `tls.client_certs[].cert`
   243  
   244  A plain text certificate to use.
   245  
   246  
   247  Type: `string`  
   248  Default: `""`  
   249  
   250  ### `tls.client_certs[].key`
   251  
   252  A plain text certificate key to use.
   253  
   254  
   255  Type: `string`  
   256  Default: `""`  
   257  
   258  ### `tls.client_certs[].cert_file`
   259  
   260  The path to a certificate to use.
   261  
   262  
   263  Type: `string`  
   264  Default: `""`  
   265  
   266  ### `tls.client_certs[].key_file`
   267  
   268  The path of a certificate key to use.
   269  
   270  
   271  Type: `string`  
   272  Default: `""`  
   273  
   274  ### `auth`
   275  
   276  Optional configuration of NATS authentication parameters.
   277  
   278  
   279  Type: `object`  
   280  
   281  ### `auth.nkey_file`
   282  
   283  An optional file containing a NKey seed.
   284  
   285  
   286  Type: `string`  
   287  Default: `""`  
   288  
   289  ```yaml
   290  # Examples
   291  
   292  nkey_file: ./seed.nk
   293  ```
   294  
   295  ### `auth.user_credentials_file`
   296  
   297  An optional file containing user credentials which consist of an user JWT and corresponding NKey seed.
   298  
   299  
   300  Type: `string`  
   301  Default: `""`  
   302  
   303  ```yaml
   304  # Examples
   305  
   306  user_credentials_file: ./user.creds
   307  ```
   308  
   309