AWS Cloud Operations Blog
Detect and respond to security threats in near real-time using Amazon Managed Grafana
Security is “job zero” at AWS. It’s crucial to gain deeper insights into your AWS infrastructure’s security posture to respond quickly to threats. The ability to centrally monitor and visualize the security findings make it easier for you to identify any security threats or gaps and also keep the principle of least privilege in focus. You can visualize the insights into those security findings across multiple accounts using Amazon Managed Grafana that retrieves and refreshes the data periodically.
AWS Security Hub offers a comprehensive overview of your AWS security status, allowing you to compare it with industry standards and best practices. Organizations may have additional requirements to centralize AWS Security Hub findings and integrate them with other operational data. Some of the benefits include consolidating AWS Security Hub findings across regions into a single dashboard view, and centralizing and correlating various security & compliance data along with operational data into one dashboard.
In this post we will show you how you can centralize your AWS Security Hub findings, that provide a single-pane-of-glass on workloads running on AWS cloud using Amazon Managed Grafana.
We will demonstrate similar integration with Amazon GuardDuty and Amazon Inspector through another post.
Architecture Overview:
Figure 1: Architecture Overview
Please refer to the details on components of the solution depicted in the above architecture:
- AWS Security Hub – AWS Security Hub is a cloud security posture management service that performs security best practices checks, aggregates alerts, and enables automated remediation.
- Amazon EventBridge Rule – Amazon EventBridge rule will be triggered on a new finding or an update to existing finding in AWS Security Hub.
- Custom AWS Lambda to process the Event – An AWS Lambda function to extract and transform the complex nested AWS Security Hub finding to a simpler JSON format that is more suitable to perform further analytics.
- Amazon Simple Storage Service (Amazon S3) bucket to receive the processed event – The AWS Lambda function delivers each finding to this Amazon S3 bucket.
- AWS Glue crawler and AWS Glue Data Catalog – Configure an AWS Glue crawler to run every hour to parse the JSON data stored in Amazon S3 and update the AWS Glue Data Catalog containing the JSON table schema, metadata, and database partitions. This metadata is required to perform queries against the data in Amazon S3.
- Amazon Athena Workgroup – Amazon Athena is used to look at the schema from the AWS Glue Data Catalog and query the data in S3. The Amazon Managed Grafana Dashboard must have permissions to execute queries against the Amazon S3 data using Amazon Athena Workgroup and AWS Glue Data Catalog.
- Amazon Managed Grafana – Deploy a dashboard using Amazon Managed Grafana to visualize data.
Using the AWS CloudFormation template provided in this blog, deploy the required resources in the same AWS Region and AWS account containing the Security Hub service where findings of all regions and accounts are aggregated into.
Prerequisites:
- Enable AWS Security Hub in member accounts. Enable required security standards, AWS native service integration, and partner integrations in all the member accounts across your AWS Regions.
- Set up your AWS Security Hub administrator account. Designate one of the AWS accounts within your AWS Organizations to be a delegated administrator for AWS Security Hub. This account can manage and receive findings across member accounts.
- Enable Cross Region Aggregation.
- Set up Amazon Athena workgroups.
- Set up Amazon Managed Grafana workspace. For information, and steps for creating the Amazon Managed Grafana workspace, see Creating a Workspace.
- Amazon Managed Grafana allows you to configure user access through AWS IAM Identity Center or other Identity Providers (IdP) based on SAML. Review Amazon Managed Grafana supports direct SAML integration with identity providers.
- In this post, you will be using the AWS IAM Identity Center option. To set up authentication and authorization, follow the instructions in the Amazon Managed Grafana User Guide to enable AWS IAM Identity Center.
- To use AWS data source configuration, first use the Amazon Managed Grafana console to enable service-managed AWS Identity and Access Management (IAM) roles that grants the workspace with AWS IAM policies necessary to access resources in your AWS Account/Organization. Then, use the Amazon Managed Grafana workspace console to add Amazon Athena data source.
Once you have all the prerequisites in place, follow the instructions below for visualizing AWS Security Hub findings on Amazon Managed Grafana.
Deployment Steps:
Step 1: Launch the AWS CloudFormation template
Download and launch this AWS CloudFormation template to deploy AWS Lambda, Amazon S3 Bucket, AWS Glue Crawler, AWS Glue Database and its related components.
Note: Some of the resources that this stack deploys incur costs when in use.
Follow these steps to generate your resources utilizing an AWS CloudFormation template:
- Sign in to the AWS Management Console.
- Navigate to the AWS CloudFormation console > Create Stack > “With new resources”.
- Upload the yaml template file and choose Next.
- Specify a “Stack name” and choose Next.
- Leave the “Configure stack options” at default values and choose Next.
- Review the details on the final screen and under “Capabilities” check the box for “I acknowledge that AWS CloudFormation might create IAM resources with custom names”.
- Choose Submit.
Figure 2: Acknowledgement
Note: You can review the progress of your new stack under AWS CloudFormation > Stacks > [StackName] > Events tab
Once the Stack is created successfully, you will see the following resources deployed: Amazon EventBridge scheduler, AWS Lambda Function, Amazon S3 Bucket, AWS Glue Crawler, AWS Glue Database and the corresponding AWS IAM Roles and Policies are created successfully.
Step 2: Create View in Amazon Athena using the below queries created as part of the AWS CloudFormation stack
- Go to Amazon Athena > Query editor > Saved queries tab and choose the query named “AWS-securityhub”.
Note: Workgroup created is named “Primary”
Figure 3: Amazon Athena Saved Queries
- On the Query editor, verify the Data source, Database and Table names while running the query. Upon successful execution, the query creates a View named “security_hub_findings”.
Figure 4: Amazon Athena Query Editor
Step 3: Configure Amazon Athena Data Source in Amazon Managed Grafana
- Access the Amazon Managed Grafana console through the provided Amazon Managed Grafana workspace URL and log in using the user credentials you’ve set up.
- Navigate to Administration > Data sources and select Amazon Athena from the options.
- Adjust the Amazon Athena settings by specifying the Default Region (us-east-1), Data source (AWSDataCatalog), Database (aws-security-hub-db), Workgroup (primary), and set the Output Location for your Amazon Athena query.
- Choose “Save & test” to confirm that the data source is functioning properly. You can now begin querying and visualizing metrics from the AWS environment.
Note: If you encounter a permission denied error, ensure that the Amazon Managed Grafana service role permissions, as discussed in the previous step, are correctly configured.
Figure 5: Amazon Athena as Data source
Step 4: Create an Amazon Managed Grafana Dashboard
Amazon Managed Grafana is a fully managed service designed to simplify the process of creating, configuring, and sharing interactive dashboards and charts for monitoring your data. It offers the ability to establish alerts and notifications based on specific conditions or thresholds, enabling swift identification and response to issues.
In this next step, we will utilize Amazon Managed Grafana to generate a new AWS Security Hub findings detection dashboard.
- Retrieve the AWS Security Hub findings dashboard JSON file from this link.
- Import the dashboard by navigating to Dashboards > New and selecting Import in the Amazon Managed Grafana console. For additional information on exporting and importing dashboards, refer to the documentation.
Figure 6: Amazon Managed Grafana Dashboard
Finally, AWS Security Hub findings are integrated into Amazon Managed Grafana. This dashboard updates every 5 minutes, querying the materialized views established in Amazon Athena.
Furthermore, Amazon Managed Grafana’s alerting system delivers strong and actionable alerts, enabling us to swiftly identify system issues as soon as they arise. For further insights into Amazon Managed Grafana alerting, please visit the “Alerts in Amazon Managed Grafana” section.
Clean up
To avoid incurring future charges, delete all resources used in this post.
- Empty Amazon S3 bucket before deleting the AWS CloudFormation stack.
- Delete AWS CloudFormation Stack
- Delete Amazon Managed Grafana Workspace
- Delete Amazon Athena workgroup
In this blog post, we showed how you can visualize and analyze your AWS Security Hub with Amazon Managed Grafana. By identifying potential threats quickly, sensitive data can be safeguarded more effectively. Near real-time dashboards allow for proactive measures, ensuring that critical workload remains secure.
To learn more and get hands-on experience on AWS observability services, check the One Observability Workshop.