This document describes how to use Cloud Logging to view and analyze
threat logs and traffic logs generated by Cloud Intrusion Detection System (Cloud IDS). Threat logs document
network-based threats such as malware, spyware, and command-and-control
attacks. Traffic logs document network flows monitored by Cloud IDS
endpoints. You can use these logs to monitor VPC communication, investigate
vulnerabilities, and meet compliance goals.

## Threat logs

You can view logs generated due to threats in your network in Cloud Logging.
The logs use a JSON format with the following fields:

- `threat_id`: the unique Palo Alto Networks threat identifier.
- `name`: name of the threat.
- `alert_severity`: severity of the threat. One of `INFORMATIONAL`, `LOW`, `MEDIUM`, `HIGH`, or `CRITICAL`.
- `type`: type of the threat.
- `category`: subtype of the threat.
- `alert_time`: time when the threat was discovered.
- `network`: customer network in which the threat was discovered.
- `source_ip_address`: suspected traffic's source IP address. When you use a Google Cloud load balancer the true client IP address is not available, and this value is the IP address range of the Google Front End (GFE). The value can be `130.211.0.0/22` or `35.191.0.0/16`.
- `destination_ip_address`: suspected traffic's destination IP address.
- `source_port`: suspected traffic's source port.
- `destination_port`: suspected traffic's destination port.
- `ip_protocol`: suspected traffic's IP protocol.
- `application`: suspected traffic's application type---for example, SSH.
- `direction`: suspected traffic's direction (client-to-server or server-to-client).
- `session_id`: an internal numerical identifier applied to each session.
- `repeat_count`: number of sessions with the same source IP, destination IP, application, and type seen within 5 seconds.
- `uri_or_filename`: URI or filename of the relevant threat, if applicable.
- `cves`: a list of CVEs associated with the threat
- `details`: additional information about the type of threat, taken from Palo Alto Networks' ThreatVault.

The previous JSON fields are nested under the log's `jsonPayload` field. The
log name for threat logs is
`projects/<consumer-project>/logs/ids.googleapis.com%2Fthreat`.

In addition, the log's `labels.id` field contains the Cloud IDS endpoint's
name, and its `resource.type` field is `ids.googleapis.com/Endpoint`.

### Sample query

This query in Cloud Logging queries the IDS threat log in cloud project
`my-project`, returning all threats reported by the
`my-endpoint` endpoint between 8am-9am on April 4, 2021, PST time
(-07 timezone offset), where the threat's severity was marked HIGH.

```
logName="projects/my-project/logs/ids.googleapis.com%2Fthreat"
   AND resource.type="ids.googleapis.com/Endpoint"
   AND resource.labels.id="my-endpoint"
   AND timestamp >= "2021-04-18T08:00:00-07"
   AND timestamp <= "2021-04-18T09:00:00-07"
   AND jsonPayload.alert_severity=("HIGH" OR "CRITICAL")
```

### Retention policy

Retention is determined by the storage buckets in which the logs are located.
By default, logs are placed in the `_Default` bucket, and by default this bucket
has a retention policy of 30 days.

You can choose to filter logs to different buckets. In addition, retention is
configurable.

If you want a different retention policy than the default 30 days, you can do
one of the following:

- Filter all logs into another bucket and configure a retention policy.
- Configure a custom retention policy for the `_Default` bucket. This will affect all other logs in the `_Default` bucket.

## Traffic logs

You can view logs generated due to network traffic in Cloud Logging.
The logs use a JSON format with the following fields:

- `start_time`: the time of the session start.
- `elapsed_time`: the elapsed time of the session.
- `network`: the network associated with the IDS endpoint.
- `source_ip_address`: the source IP address of the packet.
- `source_port`: the source port of the traffic.
- `destination_ip_address`: the destination IP address of the packet.
- `destination_port`: the destination port of the traffic.
- `ip_protocol`: the IP protocol of the packet.
- `application`: the application associated with the session.
- `session_id`: an internal numerical identifier applied to each session.
- `repeat_count`: the number of sessions with the same source IP, destination IP, application, and type seen within 5 seconds.
- `total_bytes`: the total number of bytes transferred in the session.
- `total_packets`: the total number of packets transferred in the session.