> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Audit setup

> This guide will walk you through the process of setting up the Audit service and configuring it to meet your needs.

## Infrastructure prerequisites

The Audit service requires the following components to be set up before it can be started:

* **Docker engine**
* **Kafka**
* **Elasticsearch**

## Dependencies

The Audit service is built as a Docker image and runs on top of Kafka and Elasticsearch. Therefore, these services must be set up and running before starting the Audit service.

* [**Kafka configuration**](./setup-guides-overview#kafka)
* [**Authorization & access roles**](./setup-guides-overview#authorization--access-roles)
* [**Elasticsearch**](#configuring-elasticsearch)
* [**Logging**](./setup-guides-overview#logging)

## Configuration

### Configuring Kafka

To configure the Kafka server for the Audit service, set the following environment variables:

* `SPRING_KAFKA_BOOTSTRAP_SERVERS` - address of the Kafka server, it should be in the format "host:port"
* `SPRING_KAFKA_CONSUMER_GROUP_ID` - the consumer group ID to be used for the audit logs
* `KAFKA_CONSUMER_THREADS` - the number of Kafka consumer threads to be used for processing audit logs
* `KAFKA_TOPIC_AUDIT_IN` - the topic key for receiving audit logs

### Configuring Elasticsearch

Configure Elasticsearch connection for audit data storage:

| Variable                                        | Description                                 | Default Value | Example                |
| ----------------------------------------------- | ------------------------------------------- | ------------- | ---------------------- |
| `SPRING_ELASTICSEARCH_REST_PROTOCOL`            | Connection protocol                         | `https`       | `https`                |
| `SPRING_ELASTICSEARCH_REST_URIS`                | URL(s) of Elasticsearch nodes (no protocol) | -             | `elasticsearch:9200`   |
| `SPRING_ELASTICSEARCH_REST_DISABLESSL`          | Disable SSL verification                    | `false`       | `false`                |
| `SPRING_ELASTICSEARCH_REST_USERNAME`            | Authentication username                     | -             | `elastic`              |
| `SPRING_ELASTICSEARCH_REST_PASSWORD`            | Authentication password                     | -             | `your-secure-password` |
| `SPRING_ELASTICSEARCH_INDEXSETTINGS_DATASTREAM` | Audit data stream name                      | `audit-logs`  | `audit-logs`           |
| `SPRING_ELASTICSEARCH_INDEXSETTINGS_SHARDS`     | Number of primary shards                    | `2`           | `2`                    |
| `SPRING_ELASTICSEARCH_INDEXSETTINGS_REPLICAS`   | Number of replica shards                    | `2`           | `2`                    |

### Configuring logging

To control the log levels, set the following environment variables:

* `LOGGING_LEVEL_ROOT` - the log level for the root Spring Boot microservice logs
* `LOGGING_LEVEL_APP` - the log level for app-level logs

<Warning>
  Make sure to overwrite the placeholders (where needed) with the appropriate values before starting the service.
</Warning>


## Related topics

- [FlowX.AI Audit](/4.6.0/docs/platform-deep-dive/core-extensions/audit.md)
- [Application manager setup](/4.6.0/setup-guides/application-manager.md)
- [FlowX Admin setup](/4.6.0/setup-guides/admin-setup-guide.md)
- [FlowX Engine setup](/4.6.0/setup-guides/flowx-engine-setup-guide/engine-setup.md)
- [FlowX CMS setup](/4.6.0/setup-guides/cms-setup.md)
