NATS KV icon

NATS KV

Interact with NATS JetStream Key-Value Store - manage buckets and keys

Actions8

Overview

This node interacts with the NATS JetStream Key-Value (KV) Store, specifically managing KV buckets and keys within those buckets. The "Get Status" operation for the "Bucket" resource retrieves the current status or metadata of a specified KV bucket. This is useful for monitoring bucket health, configuration, or existence before performing further operations like adding or retrieving keys.

Practical examples include:

  • Checking if a bucket exists and is accessible before writing data.
  • Retrieving bucket configuration details to audit or log KV store usage.
  • Monitoring bucket status in automated workflows that depend on KV storage state.

Properties

Name Meaning
Bucket Name The name of the KV bucket to operate on. Bucket names can only contain alphanumeric characters, dashes, and underscores.

Output

The output JSON contains the status information of the specified KV bucket. This typically includes metadata such as bucket configuration, creation time, number of keys, or other relevant status details returned by the NATS JetStream KV API.

No binary data output is produced by this operation.

Example output structure (conceptual):

{
  "bucket": "my-bucket",
  "status": {
    "created": "2023-01-01T12:00:00Z",
    "keysCount": 42,
    "maxHistory": 5,
    "ttl": 3600,
    "description": "Sample bucket description"
  }
}

Dependencies

  • Requires an active connection to a NATS JetStream server with access to the KV store feature.
  • Needs an API key credential configured in n8n for authenticating with the NATS server.
  • Uses the nats client library bundled internally for communication.
  • Proper network connectivity and permissions to access the specified bucket are necessary.

Troubleshooting

  • Invalid Bucket Name: Bucket names must only contain alphanumeric characters, dashes, and underscores. Using invalid characters will cause validation errors.
  • Unknown Bucket Operation: If the operation name is incorrect or unsupported, the node throws an error indicating the unknown operation.
  • Connection Issues: Failure to connect to the NATS server due to wrong credentials, network issues, or server unavailability will result in connection errors.
  • Bucket Not Found: Attempting to get the status of a non-existent bucket may return an error or empty response depending on the server behavior.
  • To handle errors gracefully, enable "Continue On Fail" in the node settings to allow workflow execution to proceed despite individual item failures.

Links and References

Discussion