Note
Webhooks might be a good alternative to the audit log or API polling for certain use cases. Webhooks are a way for GitHub to notify your server when specific events occur for a repository, organization, or enterprise. Compared to the API or searching the audit log, webhooks can be more efficient if you just want to learn and possibly log when certain events occur on your enterprise, organization, or repository. See "Webhooks documentation."
About audit log streaming
You can help protect intellectual property and maintain compliance for your company by using streaming to keep copies of your audit log data. The audit log details events such as changes to settings and access, user membership, app permissions, and more. See "Audit log events for your enterprise", "Audit log events for your organization", and "Security log events."
Streaming audit log data has these benefits:
- Data exploration. Examine streamed events using your preferred tool for querying large quantities of data. The stream contains both audit events and Git events across the entire enterprise account.
- Data continuity. If you pause a stream, it retains a buffer for seven days, so there is no data loss for the first week. If the stream remains paused for more than seven days, it will resume from a point one week prior to the current time. If paused for three weeks or more, the stream won't retain any data and will start anew from the current timestamp.
- Data retention. Keep your exported audit logs and Git events data as long as you need to.
You can set up, pause, or delete a stream at any time. The stream exports audit and Git events data for all of the organizations in your enterprise, for activity from the time the stream is enabled onwards.
All streamed audit logs are sent as compressed JSON files. The filename format is inYYYY/MM/HH/MM/<uuid>.json.gz
.
Note
GitHub uses an at-least-once delivery method. Due to certain network or system issues, some events may be duplicated.
Health checks for audit log streams
Every 24 hours, a health check runs for each stream. If a stream is set up incorrectly, an email will be sent to the enterprise owners. To avoid audit log events being dropped from the stream, a misconfigured stream must be fixed within six days.
To fix your streaming configuration, follow the steps in "Setting up audit log streaming."
Setting up audit log streaming
To set up the audit log stream, follow the instructions for your provider:
Note
To get a list of IP address ranges that GitHub uses for connections to the streaming endpoint, use the REST API. The meta
endpoint for GitHub Enterprise Cloud includes a hooks
key with a list of the IP addresses. See "REST API endpoints for meta data."
Setting up streaming to Amazon S3
You can set up streaming to S3 with access keys or, to avoid storing long-lived secrets in GitHub Enterprise Cloud, with OpenID Connect (OIDC).
- Setting up streaming to S3 with access keys
- Setting up streaming to S3 with OpenID Connect
- Disabling streaming to S3 with OpenID Connect
- Integrating with AWS CloudTrail Lake
Setting up streaming to S3 with access keys
To set up audit log streaming from GitHub you will need:
- Your AWS access key ID
- Your AWS secret key
For information on creating or accessing your access key ID and secret key, see Understanding and getting your AWS credentials in the AWS documentation.
From AWS:
-
Create a bucket, and block public access to the bucket. See Creating, configuring, and working with Amazon S3 buckets in the AWS documentation.
-
Create a policy that allows GitHub to write to the bucket. Copy the following JSON and replace
EXAMPLE-BUCKET
with the name of your bucket. GitHub requires only the permissions in this JSON.{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "s3:PutObject" ], "Resource": "arn:aws:s3:::EXAMPLE-BUCKET/*" } ] }
See Creating IAM policies in the AWS documentation.
From GitHub:
-
In the top-right corner of GitHub, click your profile photo.
-
Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
-
On the left side of the page, in the enterprise account sidebar, click Settings.
-
Under " Settings", click Audit log.
-
Under "Audit log", click Log streaming.
-
Select the Configure stream dropdown menu and click Amazon S3.
-
Under "Authentication", click Access keys.
-
Configure the stream settings.
- Under "Region", select the bucket's region. For example,
us-east-1
. - Under "Bucket", type the name of the bucket you want to stream to. For example,
auditlog-streaming-test
. - Under "Access Key ID", type your access key ID. For example,
ABCAIOSFODNN7EXAMPLE1
. - Under "Secret Key", type your secret key. For example,
aBcJalrXUtnWXYZ/A1MDENG/zPxRfiCYEXAMPLEKEY
.
- Under "Region", select the bucket's region. For example,
-
To verify that GitHub can connect and write to the Amazon S3 endpoint, click Check endpoint.
-
After you have successfully verified the endpoint, click Save.
Setting up streaming to S3 with OpenID Connect
From AWS:
-
Add the GitHub OIDC provider to IAM. See Creating OpenID Connect (OIDC) identity providers in the AWS documentation.
- For the provider URL, use
https://oidc-configuration.audit-log.githubusercontent.com
. - For "Audience", use
sts.amazonaws.com
.
- For the provider URL, use
-
Create a bucket, and block public access to the bucket. See Creating, configuring, and working with Amazon S3 buckets in the AWS documentation.
-
Create a policy that allows GitHub to write to the bucket. Copy the following JSON and replace
EXAMPLE-BUCKET
with the name of your bucket. GitHub requires only the permissions in this JSON.{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "s3:PutObject" ], "Resource": "arn:aws:s3:::EXAMPLE-BUCKET/*" } ] }
See Creating IAM policies in the AWS documentation.
-
Configure the role and trust policy for the GitHub IdP. See Creating a role for web identity or OpenID Connect Federation (console) in the AWS documentation.
-
Add the permissions policy you created earlier to allow writes to the bucket.
-
Edit the trust relationship to add the
sub
field to the validation conditions, replacingENTERPRISE
with the name of your enterprise."Condition": { "StringEquals": { "oidc-configuration.audit-log.githubusercontent.com:aud": "sts.amazonaws.com", "oidc-configuration.audit-log.githubusercontent.com:sub": "https://github.com/ENTERPRISE" } }
-
Make note of the Amazon Resource Name (ARN) of the created role.
-
From GitHub:
-
In the top-right corner of GitHub, click your profile photo.
-
Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
-
On the left side of the page, in the enterprise account sidebar, click Settings.
-
Under " Settings", click Audit log.
-
Under "Audit log", click Log streaming.
-
Select the Configure stream dropdown menu and click Amazon S3.
-
Under "Authentication", click OpenID Connect.
-
Configure the stream settings.
- Under "Region", select the bucket's region. For example,
us-east-1
; an option for Auto Discovery is also available. - Under "Bucket", type the name of the bucket you want to stream to. For example,
auditlog-streaming-test
. - Under "ARN Role" type the ARN role you noted earlier. For example,
arn:aws::iam::1234567890:role/github-audit-log-streaming-role
.
- Under "Region", select the bucket's region. For example,
-
To verify that GitHub can connect and write to the Amazon S3 endpoint, click Check endpoint.
-
After you have successfully verified the endpoint, click Save.
Disabling streaming to S3 with OpenID Connect
To disable streaming to S3 with OIDC, delete the GitHub OIDC provider you created in AWS when you set up streaming. See Creating OpenID Connect (OIDC) identity providers in the AWS documentation.
If you disable streaming due to a security vulnerability in OIDC, after you delete the provider, set up streaming with access keys until the vulnerability is resolved. See "Setting up streaming to S3 with access keys."
Integrating with AWS CloudTrail Lake
You can consolidate your audit logs by integrating streaming to S3 with AWS CloudTrail Lake. See the AWS CloudTrail Documentation or the GitHub Audit Log to CloudTrail Open Audit in the aws-samples/aws-cloudtrail-lake-github-audit-log
repository.
Setting up streaming to Azure Blob Storage
Note
Audit log streaming to blob storage in Azure Government is not supported.
Before setting up a stream in GitHub, first create a storage account and a container in Microsoft Azure. See Introduction to Azure Blob Storage in the Microsoft documentation.
To configure the stream, you need the URL of a SAS token.
From the Microsoft Azure portal:
- On the Home page, click Storage Accounts.
- Under "Name", click the name of the storage account you want to use.
- Under "Data storage", click Containers.
- Click the name of the container you want to use.
- In the left sidebar, under "Settings", click Shared access tokens.
- Select the Permissions dropdown menu, then select
Create
andWrite
and deselect all other options. - Set an expiry date that complies with your secret rotation policy.
- Click Generate SAS token and URL.
- Copy the value of the Blob SAS URL field that's displayed. You will use this URL in GitHub.
From GitHub:
- In the top-right corner of GitHub, click your profile photo.
- Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
- On the left side of the page, in the enterprise account sidebar, click Settings.
- Under " Settings", click Audit log.
- Under "Audit log", click Log streaming.
- Select the Configure stream dropdown menu and click Azure Blob Storage.
- On the configuration page, enter the blob SAS URL that you copied in Azure. The Container field is auto-filled based on the URL.
- Click Check endpoint to verify that GitHub can connect and write to the Azure Blob Storage endpoint.
- After you have successfully verified the endpoint, click Save.
Setting up streaming to Azure Event Hubs
Note
Event Hubs instances in Azure Government are not supported.
Before setting up a stream in GitHub, you need:
- An event hub namespace in Microsoft Azure
- An event hub instance within the namespace (see Quickstart: Create an event hub using Azure portal in the Microsoft documentation)
From the Microsoft Azure portal:
- At the top of the page, use the search box to search for "Event Hubs".
- Select Event Hubs. The names of your event hubs are listed.
- Make a note of the name of the event hub to which you want to stream. Click the event hub.
- In the left menu, click Shared Access Policies.
- Select a shared access policy from the list of policies, or create a new policy.
- Copy the connection string from the Connection string-primary key field.
From GitHub:
- In the top-right corner of GitHub, click your profile photo.
- Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
- On the left side of the page, in the enterprise account sidebar, click Settings.
- Under " Settings", click Audit log.
- Under "Audit log", click Log streaming.
- Select the Configure stream dropdown and click Azure Event Hubs.
- On the configuration page, enter:
- The name of the Azure Event Hubs instance.
- The connection string.
- Click Check endpoint to verify that GitHub can connect and write to the Azure Events Hub endpoint.
- After you have successfully verified the endpoint, click Save.
Setting up streaming to Datadog
To set up streaming to Datadog, create a client token or an API key in Datadog, then configure audit log streaming in GitHub Enterprise Cloud using the token for authentication. You do not need to create a bucket or other storage container in Datadog.
After you set up streaming to Datadog, you can see your audit log data by filtering by "github.audit.streaming." See Log Management.
-
If you don't already have a Datadog account, create one.
-
In Datadog, generate a client token or an API key and then click Copy key. See API and Application Keys in Datadog Docs.
-
In the top-right corner of GitHub, click your profile photo.
-
Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
-
On the left side of the page, in the enterprise account sidebar, click Settings.
-
Under " Settings", click Audit log.
-
Under "Audit log", click Log streaming.
-
Select the Configure stream dropdown and click Datadog.
-
In the Token field, paste the token you copied earlier.
-
Select the Site dropdown and click your Datadog site. To determine your site, compare your Datadog URL to the table in Datadog sites in Datadog Docs.
-
To verify that GitHub can connect and write to the Datadog endpoint, click Check endpoint.
-
After you have successfully verified the endpoint, click Save.
-
After a few minutes, confirm that audit log data appears on the Logs tab in Datadog. If it doesn't appear, confirm that your token and site are correct in GitHub.
Setting up streaming to Google Cloud Storage
To set up streaming to Google Cloud Storage, create a service account in Google Cloud with the appropriate credentials and permissions, then configure audit log streaming in GitHub Enterprise Cloud using the service account's credentials for authentication.
-
Create a service account for Google Cloud. You do not need to set access controls or IAM roles for this account. See Creating and managing service accounts in the Google Cloud documentation.
-
Create a JSON key for the service account, and store the key securely. See Creating and managing service account keys in the Google Cloud documentation.
-
If you haven't yet, create a bucket. See Creating storage buckets in the Google Cloud documentation.
-
Give the service account the Storage Object Creator role for the bucket. See Using Cloud IAM permissions in the Google Cloud documentation.
-
In the top-right corner of GitHub, click your profile photo.
-
Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
-
On the left side of the page, in the enterprise account sidebar, click Settings.
-
Under " Settings", click Audit log.
-
Under "Audit log", click Log streaming.
-
Select the Configure stream dropdown and click Google Cloud Storage.
-
Under "Bucket", type the name of your Google Cloud Storage bucket.
-
Under "JSON Credentials", paste the entire contents of your service account's JSON key file.
-
To verify that GitHub can connect and write to the Google Cloud Storage bucket, click Check endpoint.
-
After you have successfully verified the endpoint, click Save.
Setting up streaming to Splunk
To stream audit logs to Splunk's HTTP Event Collector (HEC) endpoint, make sure that the endpoint is configured to accept HTTPS connections. See Set up and use HTTP Event Collector in Splunk Web in the Splunk documentation.
Note
GitHub validates the HEC endpoint via <Domain>:port/services/collector
. If self-hosting the endpoint (such as with Splunk HEC Receiver via OpenTelemetry), make sure it's reachable at this destination.
-
In the top-right corner of GitHub, click your profile photo.
-
Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
-
On the left side of the page, in the enterprise account sidebar, click Settings.
-
Under " Settings", click Audit log.
-
Under "Audit log", click Log streaming.
-
Select the Configure stream dropdown and click Splunk.
-
On the configuration page, enter:
-
The domain where the application you want to stream to is hosted.
If you're using Splunk Cloud,
Domain
should behttp-inputs-<host>
, wherehost
is the domain you use in Splunk Cloud. For example,http-inputs-mycompany.splunkcloud.com
.If you're using the free trial version of Splunk Cloud,
Domain
should beinputs.<host>
, wherehost
is the domain you use in Splunk Cloud. For example,inputs.mycompany.splunkcloud.com
. -
The port on which the application accepts data.
If you're using Splunk Cloud,
Port
should be443
.If you're using the free trial version of Splunk Cloud,
Port
should be8088
. -
A token that GitHub can use to authenticate to the third-party application.
-
-
Leave the Enable SSL verification check box selected.
Audit logs are always streamed as encrypted data, however, with this option selected, GitHub verifies the SSL certificate of your Splunk instance when delivering events. SSL verification helps ensure that events are delivered to your URL endpoint securely. Verification is optional, but we recommend you leave SSL verification enabled.
-
Click Check endpoint to verify that GitHub can connect and write to the Splunk endpoint.
-
After you have successfully verified the endpoint, click Save.
Pausing audit log streaming
Pause the stream to perform maintenance on the receiving application without losing audit data. Audit logs are stored for up to seven days on GitHub and are then exported when you unpause the stream.
Datadog only accepts logs from up to 18 hours in the past. If you pause a stream to a Datadog endpoint for more than 18 hours, you risk losing logs that Datadog won't accept after you resume streaming.
- In the top-right corner of GitHub, click your profile photo.
- Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
- On the left side of the page, in the enterprise account sidebar, click Settings.
- Under " Settings", click Audit log.
- Under "Audit log", click Log streaming.
- To the right of your configured stream, click Pause stream.
- A confirmation message displays. Click Pause stream to confirm.
To restart streaming, click Resume stream.
Deleting the audit log stream
- In the top-right corner of GitHub, click your profile photo.
- Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
- On the left side of the page, in the enterprise account sidebar, click Settings.
- Under " Settings", click Audit log.
- Under "Audit log", click Log streaming.
- Under "Danger zone", click Delete stream.
- A confirmation message displays. Click Delete stream to confirm.
Enabling audit log streaming of API requests
Note
This feature is currently in public preview and subject to change.
- In the top-right corner of GitHub, click your profile photo.
- Depending on your environment, click Your enterprise, or click Your enterprises then click the enterprise you want to view.
- On the left side of the page, in the enterprise account sidebar, click Settings.
- Under " Settings", click Audit log.
- Under "Audit log", click Settings.
- Under "API Requests", select Enable API Request Events.
- Click Save.