To audit allowed and denied connections, verify your network policies, and
troubleshoot blocked traffic in Google Distributed Cloud user clusters, you can enable
network policy logging. This document shows you where the logs are stored on
cluster nodes and which tool to use to export them. To learn how to configure
which events are logged and how logs are formatted, see
[Using network policy logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging.md.txt).

## Overview

[Network
policies](https://kubernetes.io/docs/concepts/services-networking/network-policies/)
are Pod-level firewalls; they specify network traffic that Pods are allowed to
send and receive. Network policy logs record network policy events. You can
log all events or you can [configure logging
selectively](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging#configuring_network_policy_logging)
based on the following criteria:

- Allowed connections.
- Denied connections.
- Connections allowed by specific policies.
- Denied connections to Pods in specific namespaces.

## Before you begin

Network policy logging is supported in user clusters that use
[Dataplane V2](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/dataplane-v2.md.txt). You can enable
Dataplane V2 when creating a new user cluster by using the
[`enableDataplaneV2`](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest.md.txt#enabledataplanev2-field)
field in the user cluster configuration file.

## Enabling logging

Network policy logging is not enabled by default. For information on enabling
logging and selecting which events to log, see [Configuring network policy
logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging#configuring_network_policy_logging).

## Accessing logs

The network policy logs generated on each cluster node are available locally on
the cluster nodes at
`/var/log/network/policy_actiontimestamp.log`. A new
timestamped log file is created when the current log file reaches 10 MB. Up to
five previous log files are stored.

## Exporting logs

We recommend that you use [Fluent Bit](https://fluentbit.io/) to export
logs from your cluster nodes. Fluent Bit is an open source log processor
and forwarder that supports exporting to
Cloud Logging and many [other data
sinks](https://docs.fluentbit.io/manual/pipeline/outputs).

## What's next

- Learn [how to configure network policy logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging.md.txt)
- Learn how to [create a network policy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy.md.txt)