Operating purposes throughout hybrid or multicloud environments creates a standard problem: fragmented logs scattered throughout totally different platforms. This fragmentation complicates monitoring, slows troubleshooting, and reduces operational visibility. To deal with this, many organizations search to implement safe log ingestion from all environments right into a centralized platform.
Amazon OpenSearch Service supplies a unified resolution for real-time search, analytics, and log administration throughout your complete infrastructure. Amazon OpenSearch Ingestion, a completely managed knowledge collector, simplifies knowledge processing with built-in capabilities to filter, remodel, and enrich your logs earlier than evaluation.
Nevertheless, securely sending logs from non-AWS environments presents a problem. Each request to OpenSearch Ingestion requires AWS Signature Model 4 (AWS SigV4) authentication, historically requiring long-term credentials that introduce safety dangers. AWS Identification and Entry Administration Roles Anyplace solves this downside by offering short-term credentials for workloads operating outdoors AWS.
On this publish, we reveal learn how to configure Fluent Bit, a quick and versatile log processor and router supported by varied working methods, to securely ship logs from any surroundings to OpenSearch Ingestion utilizing IAM Roles Anyplace. This strategy alleviates the necessity for long-term credentials whereas offering a complete view of your utility logs throughout all environments—bettering safety, simplifying operations, and enhancing your capacity to rapidly resolve points.
Options overview
The answer on this publish makes use of Fluent Bit to gather logs, retrieve short-term credentials from IAM Roles Anyplace, and signal HTTP log ingestion requests with AWS SigV4 earlier than sending them to the OpenSearch Ingestion pipeline. The next diagram reveals the structure.
This resolution provisions the next key elements:
- Certificates authority – For this publish, we use AWS Non-public Certificates Authority (AWS Non-public CA) because the certificates authority (CA) supply. Alternatively, you possibly can combine with an exterior CA; for extra particulars, see IAM Roles Anyplace with an exterior certificates authority. Certificates issued from public CAs can’t be used as belief anchors for IAM Roles Anyplace.
- X.509 Certificates – We use a pattern non-public certificates saved in AWS Certificates Supervisor (ACM) and issued by AWS Non-public CA.
- IAM Roles Anyplace configuration – This consists of the next:
- Belief anchor – Establishes belief between IAM Roles Anyplace and the required CA.
- IAM position – Grants permissions for log ingestion and trusts the IAM Roles Anyplace service principal. At minimal, this position have to be granted permission for the
osis:Ingest
motion. - Profile – Defines which roles IAM Roles Anyplace can assume and the utmost permissions granted with the short-term credentials.
- OpenSearch Service area – For this publish, we use an OpenSearch Service area, which is an AWS provisioned equal of an open supply OpenSearch cluster. We create the area inside a digital non-public cloud (VPC); see VPC versus public domains for extra data. Alternatively, you need to use an Amazon OpenSearch Serverless assortment, which is an OpenSearch cluster that scales compute capability primarily based in your utility’s wants.
- OpenSearch Ingestion – That is configured to obtain logs over HTTP because the pipeline supply and ahead them to the OpenSearch Service area because the pipeline sink.
Connectivity between AWS and your hybrid or multicloud environments
You’ll be able to entry your OpenSearch Ingestion pipelines utilizing an interface VPC endpoint with push-based HTTP supply, which supplies non-public IP tackle connectivity. For manufacturing environments, we suggest utilizing these non-public connections by interface endpoints for enhanced safety.
Establishing this connectivity requires extra configuration, similar to creating an AWS Web site-to-Web site VPN connection together with your hybrid and multicloud community. Though this publish focuses on the log ingestion resolution, you’ll find detailed steerage on community connectivity within the following assets:
How Fluent Bit retrieves short-term credentials utilizing IAM Roles Anyplace
Utilizing the HTTP output plugin, Fluent Bit can ship logs to the OpenSearch Ingestion pipeline. The next diagram is a simplified view of how Fluent Bit retrieves AWS credentials.
On Linux methods, Fluent Bit can use an AWS Command Line Interface (AWS CLI) profile that makes use of the credential_process
parameter to set off an exterior course of. This exterior course of is invoked to generate or retrieve credentials in a roundabout way supported by the AWS CLI.
The next are two frequent mechanisms for the exterior course of:
Though each choices are viable, this publish focuses on IAM Roles Anyplace. On this setup, the AWS IAM Roles Anyplace Credential Helper is executed to deal with the signing course of for the CreateSession API. This returns credentials in a JSON format that Fluent Bit can devour.
As of this writing, the Fluent Bit aws_profile
configuration is supported solely on Linux. It’s untested on different Unix-based methods (similar to macOS) and isn’t carried out for Home windows.
Conditions
Earlier than you start this walkthrough, be sure you have the next:
- AWS account necessities – This consists of:
- An AWS account with permissions to deploy AWS CloudFormation templates.
- Entry to AWS CloudShell for exporting a pattern non-public certificates we are going to create utilizing AWS CloudFormation in a later step.
- Distant (hybrid or multicloud) surroundings – You have to have a distant machine with Linux-based working system. This resolution was examined on Ubuntu 24.04 with the next extra tooling put in:
Deploy AWS assets with AWS CloudFormation
Comply with these steps to deploy AWS assets required for this resolution:
- Select Launch Stack:
- Enter a novel title for Stack title. The default worth is
osis-with-iamra
. - Configure the stack parameters. Default values are offered within the following desk.
Parameter | Default worth | Description |
CACommonName | instance.com | Frequent Title for the CA |
CACountry | US | Group for the CA |
CAOrganization | Instance Org | Nation for the CA |
CAValidityInDays | 1826 | Validity interval in days for the CA certificates |
VPCCIDR | 10.0.0.0/16 | IPv4 CIDR vary for the VPC used for OpenSearch Service area |
PublicSubnetCIDR | 10.0.0.0/24 | IPv4 CIDR vary for public subnet |
PrivateSubnet1CIDR | 10.0.1.0/24 | IPv4 CIDR vary for personal subnet |
PrivateSubnet2CIDR | 10.0.2.0/24 | IPv4 CIDR vary for personal subnet |
DomainName | test-domain | Title of the OpenSearch Service area |
PipelineName | test-pipeline | Title of the OpenSearch Ingestion pipeline |
PipelineIngestionPath | /test-ingestion-path | Ingestion path for the OpenSearch Ingestion pipeline |
- Choose the acknowledgement examine field and select Create Stack.
Stack deployment takes about half-hour to finish. - When stack creation is full, navigate to the Outputs tab on the AWS CloudFormation console and be aware down the values for the assets created.
The next desk summarizes the output values.
Output | Description | Instance worth |
ACMCertificateArn | Amazon Useful resource Title (ARN) of the ACM certificates. You’ll use this for exporting certificates and personal key recordsdata utilizing the AWS CLI in a later step. | arn:aws:acm:aa-example-1:111122223333:certificates/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 |
CertificateAuthorityArn | ARN of the Non-public CA. | arn:aws:acm-pca:aa-example-1:111122223333:certificate-authority/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222 |
TrustAnchorArn | ARN of the IAM Roles Anyplace profile. You’ll use this worth for configuring credential_process for IAM Roles Anyplace in a later step. | arn:aws:rolesanywhere:aa-example-1:111122223333:trust-anchor/a1b2c3d4-5678-90ab-cdef-EXAMPLE33333 |
IngestionRoleArn | ARN of the OpenSearch Ingestion position. You’ll use this worth for configuring credential_process for IAM Roles Anyplace in a later step. | arn:aws:iam::111122223333:position/role-name-with-path |
ProfileArn | ARN of the IAM Roles Anyplace profile. You’ll use this worth for configuring credential_process for IAM Roles Anyplace in a later step. | arn:aws:rolesanywhere:aa-example-1:111122223333:profile/a1b2c3d4-5678-90ab-cdef-EXAMPLE44444 |
OpenSearchDomainEndpoint | Endpoint of the VPC OpenSearch area. You’ll use this public endpoint for querying your index after ingestion. | vpc-my-domain-123456789012.aa-example-1.es.amazonaws.com |
PipelineEndpoint | Endpoint of the OpenSearch Ingestion pipeline. You’ll use this public endpoint within the Fluent Bit configuration. | my-pipeline-123456789012.aa-example-1.osis.amazonaws.com |
PipelineIngestionPath | Ingestion path for the OpenSearch Ingestion pipeline. | /test-ingestion-path |
Export a pattern non-public certificates utilizing CloudShell
Comply with these steps to export the pattern non-public certificates created by the CloudFormation stack:
- Open CloudShell. For extra particulars, see Navigating the AWS CloudShell interface.
- Export the certificates ARN from the CloudFormation outputs. In case you modified the stack title within the earlier step, use that worth for
, in any other case use the default worth osis-with-iamra
.
- Extract the certificates and personal key recordsdata:
- Obtain the extracted certificates and personal key recordsdata from CloudShell:
/residence/cloudshell-user/certificates.pem
/residence/cloudshell-user/private_key.pem
Configure an AWS CLI profile
Comply with these steps to configure an AWS CLI profile on your log ingestion surroundings:
- Retailer the downloaded certificates and personal key to your surroundings. For an automatic strategy to generate and rotate certificates, see Arrange AWS Non-public Certificates Authority to situation certificates to be used with IAM Roles Anyplace.
- Create a brand new profile named
osis-pipeline-credentials
that invokes the credential course of. Change the placeholders together with your particular values. Discover the values for trusted-anchor-arn, profile-arn, and ingestion-role-arn in your CloudFormation stack outputs.
- Confirm your configuration. Open the
~/.aws/config
file and ensure it comprises a profile namedosis-pipeline-credentials
just like the next:
Configure Fluent Bit
Run the next command to create a Fluent Bit configuration. Change the placeholders together with your particular values. Discover the osis-pipeline-endpoint and pipeline-ingestion-path values in your CloudFormation stack outputs.
This instance configuration consists of the next:
- Makes use of the tail enter plugin to watch the
/var/log/syslog
file - Makes use of the http output plugin to flush log data to the OpenSearch Ingestion pipeline endpoint
- Makes use of the
osis-pipeline-credentials
profile to acquire short-term AWS credentials for SigV4 authentication (aws_auth
set totrue
)
Check the answer
Comply with these steps to check the setup:
- Begin the Fluent Bit consumer with the configuration file
fluent-bit.conf
that you simply created within the earlier step. Change the placeholder with the worth relevant to your surroundings. For Ubuntu 24.04, the default path of the Fluent Bit consumer is/choose/fluent-bit/bin/fluent-bit
. Modify the trail if utilizing different distributions.
sudo AWS_CONFIG_FILE=~/.aws/config
- As a result of the answer on this publish launched the OpenSearch Service area inside a VPC, you’ll need an surroundings that has connectivity to the VPC. For this publish, we create a CloudShell VPC surroundings to run the instructions within the subsequent step. Discover the VPC, subnet, and safety group to make use of out of your CloudFormation stack outputs.
- The answer that you simply deployed by AWS CloudFormation dynamically creates indexes primarily based on ingestion timestamps, format
logs-%{yyyy.MM.dd}
. You’ll be able to specify your most well-liked naming utilizing OpenSearch Ingestion index administration. You’ll be able to question your OpenSearch index utilizing your most well-liked instrument to see the ingested logs from Fluent Bit. We use awscurl in a CloudShell surroundings as proven within the following instance. Change the placeholders together with your particular values. Discover the opensearch-domain-endpoint worth in your CloudFormation stack outputs.
The next is an instance of the anticipated output:
Clear up
To keep away from future fees, take away the deployed assets:
- Delete the CloudFormation stack.
- Take away generated recordsdata from CloudShell:
rm cert_export.json encrypted_private_key.pem certificates.pem private_key.pem
Conclusion
On this publish, we demonstrated learn how to acquire short-term credentials from IAM Roles Anyplace and securely ingest logs from hybrid or multicloud environments into OpenSearch Service utilizing OpenSearch Ingestion. This strategy minimizes the danger of credential publicity whereas enabling centralized log assortment from distributed workloads. This resolution is especially invaluable for organizations managing advanced infrastructures throughout a number of environments and trying to consolidate observability knowledge in OpenSearch Service. For added particulars, check with the next assets:
You probably have questions or suggestions about this publish, please depart them within the feedback part.
In regards to the Authors
Xiaoxue Xu is a Options Architect for AWS primarily based in Toronto. She primarily works with monetary companies prospects to assist safe their workload and design scalable options on the AWS Cloud.
Simran Singh is a Senior Options Architect at AWS. On this position, he assists our massive enterprise prospects in assembly their key enterprise goals utilizing AWS. His areas of experience embrace synthetic intelligence and machine studying, safety, and bettering the expertise of builders constructing on AWS.