Operating functions 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 handle this, many organizations search to implement safe log ingestion from all environments right into a centralized platform.
Amazon OpenSearch Service gives a unified resolution for real-time search, analytics, and log administration throughout your whole infrastructure. Amazon OpenSearch Ingestion, a totally managed information collector, simplifies information processing with built-in capabilities to filter, rework, 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 drawback by offering short-term credentials for workloads operating outdoors AWS.
On this put up, we exhibit tips on 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 software logs throughout all environments—bettering safety, simplifying operations, and enhancing your capability to shortly resolve points.
Options overview
The answer on this put up 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 parts:
- Certificates authority – For this put up, we use AWS Personal Certificates Authority (AWS Personal CA) because the certificates authority (CA) supply. Alternatively, you’ll be able to 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 Personal CA.
- IAM Roles Anyplace configuration – This consists of the next:
- Belief anchor – Establishes belief between IAM Roles Anyplace and the required CA.
- IAM function – Grants permissions for log ingestion and trusts the IAM Roles Anyplace service principal. At minimal, this function 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 put up, 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 info. Alternatively, you should use an Amazon OpenSearch Serverless assortment, which is an OpenSearch cluster that scales compute capability primarily based in your software’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 possibly can entry your OpenSearch Ingestion pipelines utilizing an interface VPC endpoint with push-based HTTP supply, which gives non-public IP tackle connectivity. For manufacturing environments, we suggest utilizing these non-public connections by way of interface endpoints for enhanced safety.
Organising this connectivity requires extra configuration, resembling creating an AWS Website-to-Website VPN connection along with your hybrid and multicloud community. Though this put up focuses on the log ingestion resolution, yow will discover detailed steering on community connectivity within the following sources:
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 indirectly supported by the AWS CLI.
The next are two widespread mechanisms for the exterior course of:
Though each choices are viable, this put up 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 eat.
As of this writing, the Fluent Bit aws_profile
configuration is supported solely on Linux. It’s untested on different Unix-based methods (resembling macOS) and isn’t carried out for Home windows.
Conditions
Earlier than you start this walkthrough, ensure 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’ll create utilizing AWS CloudFormation in a later step.
- Distant (hybrid or multicloud) surroundings – You will need 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 sources with AWS CloudFormation
Observe these steps to deploy AWS sources 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 supplied 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 test 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 sources 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 Personal 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 function. You’ll use this worth for configuring credential_process for IAM Roles Anyplace in a later step. |
arn:aws:iam::111122223333:function/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
Observe 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 the event 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:
/house/cloudshell-user/certificates.pem
/house/cloudshell-user/private_key.pem
Configure an AWS CLI profile
Observe 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 Personal 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. Exchange the placeholders along 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 incorporates a profile namedosis-pipeline-credentials
just like the next:
Configure Fluent Bit
Run the next command to create a Fluent Bit configuration. Exchange the placeholders along 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 information 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
Observe these steps to check the setup:
- Begin the Fluent Bit shopper with the configuration file
fluent-bit.conf
that you simply created within the earlier step. Exchange the placeholder with the worth relevant to your surroundings. For Ubuntu 24.04, the default path of the Fluent Bit shopper is/decide/fluent-bit/bin/fluent-bit
. Alter the trail if utilizing different distributions.
sudo AWS_CONFIG_FILE=~/.aws/config
- As a result of the answer on this put up launched the OpenSearch Service area inside a VPC, you will want an surroundings that has connectivity to the VPC. For this put up, 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 way of AWS CloudFormation dynamically creates indexes primarily based on ingestion timestamps, format
logs-%{yyyy.MM.dd}
. You possibly can specify your most well-liked naming utilizing OpenSearch Ingestion index administration. You possibly can 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. Exchange the placeholders along 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 prices, take away the deployed sources:
- 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 put up, we demonstrated tips on how to get hold of 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 chance of credential publicity whereas enabling centralized log assortment from distributed workloads. This resolution is especially priceless for organizations managing advanced infrastructures throughout a number of environments and trying to consolidate observability information in OpenSearch Service. For added particulars, confer with the next sources:
When you have questions or suggestions about this put up, please go away 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 providers clients to assist safe their workload and design scalable options on the AWS Cloud.
Simran Singh is a Senior Options Architect at AWS. On this function, he assists our massive enterprise clients 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.