<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ata Ince on Medium]]></title>
        <description><![CDATA[Stories by Ata Ince on Medium]]></description>
        <link>https://medium.com/@ataince?source=rss-bc49e7be6206------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SYSdjk0UjBAmq_gVNJrOPw@2x.jpeg</url>
            <title>Stories by Ata Ince on Medium</title>
            <link>https://medium.com/@ataince?source=rss-bc49e7be6206------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:27:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ataince/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Game Backend Observability and Monitoring on AWS]]></title>
            <link>https://medium.com/clerion/game-backend-observability-and-monitoring-on-aws-115dc0c3e3db?source=rss-bc49e7be6206------2</link>
            <guid isPermaLink="false">https://medium.com/p/115dc0c3e3db</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[grafana-loki]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Ata Ince]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 08:44:25 GMT</pubDate>
            <atom:updated>2025-09-10T08:44:25.177Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9Ocb6hZvGVDXLlQ4GFVOw.jpeg" /></figure><h4>Introduction</h4><p>In this post, we’ll walk through how to build a <strong>scalable, cost-effective game backend observability and log monitoring solution</strong> using <strong>AWS EKS</strong>, <strong>Amazon S3</strong>, <strong>Loki</strong>, <strong>Fluent Bit</strong> and <strong>Grafana</strong>. We’ll also cover an optional optimization: <strong>automatically moving older logs to lower-cost S3 storage tiers</strong> with <strong>lifecycle policies</strong>.</p><h4>Why Game Backend Observability Matters</h4><p>Observability is critical for maintaining the performance, reliability, and scalability of game backend services. Proper log monitoring allows studios to quickly detect issues, optimize server performance, and deliver a seamless gaming experience.</p><h4>Architecture Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5efRHGCCIjhQNjds.png" /></figure><p>Here’s a high-level overview of the observability setup we’ll implement:</p><ol><li><strong>Game Backend Application Logs</strong> are generated on <strong>AWS EKS</strong> (Elastic Kubernetes Service).</li><li>Logs are exported and stored into an <strong>Amazon S3</strong> bucket.</li><li><strong>Loki</strong> is deployed on EKS and configured to read and index logs from Fluent Bit and chunks them on S3.</li><li><strong>Grafana</strong> is also deployed on EKS to visualize, search, and analyze the logs.</li><li><strong>Amazon S3 Lifecycle Policies</strong> are configured to automatically transition older logs to cheaper storage classes like <strong>S3 Standard-IA</strong> (Infrequent Access) or <strong>S3 Glacier</strong> for cost optimization.</li></ol><blockquote><strong><em>Note:</em></strong><em> While in this architecture we deploy Grafana on an EKS Cluster for a fully containerized solution but It’s also possible to run Grafana as a </em><strong><em>managed service</em></strong><em> using </em><strong><em>Amazon Managed Grafana</em></strong><em> or deploy it inside the </em><strong><em>EC2 Instance.</em></strong></blockquote><h4>Prerequisites for Loki</h4><ul><li>Helm 3 or above. Refer to <a href="https://helm.sh/docs/intro/install/">Installing Helm</a>. This should be installed on your local machine.</li><li>A running <strong>Kubernetes</strong> cluster on <strong>AWS</strong>. A simple way to get started is by using <strong>eksctl</strong>. Refer to <a href="https://eksctl.io/">Getting started with EKSctl</a>.</li><li><strong>Kubectl</strong> installed on your local machine. Refer to <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">Install and Set Up kubectl</a>.</li><li>(Optional) <strong>AWS CLI</strong> installed on your local machine. Refer to <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html">Installing the AWS CLI</a>. This is required if you plan to use <strong>eksctl</strong> to create the <strong>EKS</strong> cluster and modify the <strong>IAM roles and policies</strong> locally.</li></ul><h4>EKS Minimum Requirements for Loki</h4><p>The minimum requirements for deploying Loki on EKS are:</p><ul><li>Kubernetes version 1.30 or above.</li><li>3 nodes for the EKS cluster.</li></ul><p>The following plugins must also be installed within the EKS cluster:</p><ul><li><strong>Amazon EBS CSI Driver</strong>: Enables Kubernetes to dynamically provision and manage EBS volumes as persistent storage for applications. We use this to provision the node volumes for Loki.</li><li><strong>CoreDNS</strong>: Provides internal DNS service for Kubernetes clusters, ensuring that services and pods can communicate with each other using DNS names.</li><li><strong>kube-proxy</strong>: Maintains network rules on nodes, enabling communication between pods and services within the cluster.</li></ul><blockquote>You must also install an <strong>OIDC (OpenID Connect) provider</strong> on the EKS cluster. This is required for the IAM roles and policies to work correctly. If you are using EKSctl, you can install the OIDC provider using the following command:</blockquote><pre>eksctl utils associate-iam-oidc-provider - cluster [cluster-name] - approve</pre><p>Output has to look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/0*EiYXI9kzRHmCTzrt.png" /></figure><h4>Step 1: Exporting Backend Application Logs to Log Agent</h4><p>First, configure your <strong>EKS</strong> workloads to export backend application logs into a Log Agent.</p><p>You can achieve this using tools like:</p><ul><li><strong>Fluent Bit</strong> or <strong>Fluentd</strong></li><li><strong>Promtail </strong>(Grafana Ecosystem)</li><li><strong>Logstash </strong>(Elastic Ecosystem)</li><li><strong>OpenTelemetry Collector</strong></li></ul><p>etc.</p><blockquote><em>In this document, we used </em><strong><em>Fluent Bit</em></strong><em> as the log agent. After deploying </em><strong><em>Fluent Bit</em></strong><em> to your </em><strong><em>EKS</em></strong><em> cluster, you need to define the </em><strong><em>OUTPUT</em></strong><em> configuration within the </em><strong><em>ConfigMap</em></strong><em>. You can find a template example below.</em></blockquote><p>Example <strong>Fluent Bit</strong> output configuration:</p><pre>[OUTPUT]<br>Name loki<br>Match *<br>Host 123456789012341235–797527364.us-east-1.elb.amazonaws.com<br>port 80<br>tls off<br>tls.verify off<br>http_user USERNAME<br>http_passwd PASSWORD<br>tenant_id foo<br>line_format json<br>labels job=fluentbit</pre><blockquote><em>For all configuration parameters and details you can visit </em><a href="https://docs.fluentbit.io/manual/pipeline/outputs/loki">Fluent Bit Docs</a><em>.</em></blockquote><h4>Step 2: Defining IAM roles and policies</h4><p>The recommended method for connecting Loki to AWS S3 is to use an IAM role. This method is more secure than using access keys and secret keys which are directly stored in the Loki configuration. The role and policy can be created using the AWS CLI or the AWS Management Console. The below steps show how to create the role and policy using the AWS CLI.</p><ol><li>Create a new directory and navigate to it. Make sure to create the files in this directory. All commands in this guide assume you are in this directory.</li><li>Create a loki-s3-policy.json file with the following content:</li></ol><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;LokiStorage&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:ListBucket&quot;,<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::&lt; CHUNK BUCKET NAME &gt;&quot;,<br>                &quot;arn:aws:s3:::&lt; CHUNK BUCKET NAME &gt;/*&quot;,<br>                &quot;arn:aws:s3:::&lt; RULER BUCKET NAME &gt;&quot;,<br>                &quot;arn:aws:s3:::&lt; RULER BUCKET NAME &gt;/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><blockquote><strong>Make sure to replace the placeholders with the names of the buckets you created earlier.</strong></blockquote><p>3. Create the IAM policy using the AWS CLI:</p><pre>aws iam create-policy — policy-name LokiS3AccessPolicy — policy-document file://loki-s3-policy.json</pre><p>4. Create a trust policy document named trust-policy.json with the following content:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Federated&quot;: &quot;arn:aws:iam::&lt; ACCOUNT ID &gt;:oidc-provider/oidc.eks.&lt;INSERT REGION&gt;.amazonaws.com/id/&lt; OIDC ID &gt;&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;oidc.eks.&lt;INSERT REGION&gt;.amazonaws.com/id/&lt; OIDC ID &gt;:sub&quot;: &quot;system:serviceaccount:loki:loki&quot;,<br>                    &quot;oidc.eks.&lt;INSERT REGION&gt;.amazonaws.com/id/&lt; OIDC ID &gt;:aud&quot;: &quot;sts.amazonaws.com&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><blockquote>Make sure to replace the placeholders with your AWS account ID, region, and the OIDC ID (you can find this in the EKS cluster configuration).</blockquote><blockquote>You can find your OIDC ID in AWS Management Console with Overview EKS Cluster:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*OmzeJlGMt0raKCtr.png" /></figure><p>5. Create the IAM role using the AWS CLI:</p><pre>aws iam create-role — role-name LokiServiceAccountRole — assume-role-policy-document file://trust-policy.json</pre><p>6. Attach the policy to the role:</p><pre>aws iam attach-role-policy — role-name LokiServiceAccountRole — policy-arn arn:aws:iam::&lt;Account ID&gt;:policy/LokiS3AccessPolicy</pre><blockquote><strong>Make sure to replace the placeholder with your AWS account ID.</strong></blockquote><p>The <strong>IAM Role and Policy</strong> configuration should match the structure shown in the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K8_AEEBpvl6iXFm7.png" /></figure><h4>Step 4: Deploying Loki</h4><p>Before we can deploy the Loki Helm chart, we need to add the Grafana chart repository to Helm. This repository contains the Loki Helm chart.</p><ol><li>Add the Grafana chart repository to Helm:</li></ol><pre>helm repo add grafana https://grafana.github.io/helm-charts</pre><p>2. Update the chart repository:</p><pre>helm repo update</pre><p>3. Create a new namespace for Loki:</p><pre>kubectl create namespace loki</pre><h4>Loki Basic Authentication</h4><p>Loki by default does not come with any authentication. Since we will be deploying Loki to AWS and exposing the gateway to the internet, we recommend adding at least basic authentication. In this guide we will give Loki a username and password:</p><ol><li>To start we will need create a .htpasswd file with the username and password. You can use the htpasswd command to create the file:</li></ol><blockquote>If you don’t have the <em>htpasswd</em> command installed, you can install it using <em>brew</em> or <em>apt-get</em> or <em>yum</em> depending on your OS.</blockquote><pre>htpasswd -c .htpasswd &lt;username&gt;</pre><p>This will create a file called <em>auth</em> with the username <em>loki</em>. You will be prompted to enter a password.</p><p>2. Create a Kubernetes secret with the .htpasswd file:</p><pre>kubectl create secret generic loki-basic-auth — from-file=.htpasswd -n loki</pre><p>This will create a secret called loki-basic-auth in the loki namespace. We will reference this secret in the Loki Helm chart configuration.</p><p>3. Create a canary-basic-auth secret for the canary:</p><pre>kubectl create secret generic canary-basic-auth \<br>  --from-literal=username=&lt;USERNAME&gt; \<br>  --from-literal=password=&lt;PASSWORD&gt; \<br>  -n loki</pre><p>We create a literal secret with the username and password for Loki canary to authenticate with the Loki gateway. <strong>Make sure to replace the placeholders with your desired username and password.</strong></p><h4>Loki Helm chart configuration</h4><p>Create a values.yaml file choosing the configuration options that best suit your requirements. Below there is an example of values.yaml files for the Loki Helm chart in <a href="https://grafana.com/docs/loki/latest/get-started/deployment-modes/#microservices-mode?src=yt&amp;mdm=social&amp;cnt=description">microservices</a> mode.</p><pre>loki:<br>   schemaConfig:<br>     configs:<br>       - from: &quot;2024-04-01&quot;<br>         store: tsdb<br>         object_store: s3<br>         schema: v13<br>         index:<br>           prefix: loki_index_<br>           period: 24h<br>   storage_config:<br>     aws:<br>       region: &lt;S3 BUCKET REGION&gt; # for example, eu-west-2  <br>       bucketnames: &lt;CHUNK BUCKET NAME&gt; # Your actual S3 bucket name, for example, loki-aws-dev-chunks<br>       s3forcepathstyle: false<br>   ingester:<br>       chunk_encoding: snappy<br>   pattern_ingester:<br>       enabled: true<br>   limits_config:<br>     allow_structured_metadata: true<br>     volume_enabled: true<br>     retention_period: 672h # 28 days retention<br>   compactor:<br>     retention_enabled: true <br>     delete_request_store: s3<br>   ruler:<br>    enable_api: true<br>    storage:<br>      type: s3<br>      s3:<br>        region: &lt;S3 BUCKET REGION&gt; # for example, eu-west-2<br>        bucketnames: &lt;RULER BUCKET NAME&gt; # Your actual S3 bucket name, for example, loki-aws-dev-ruler<br>        s3forcepathstyle: false<br>      alertmanager_url: http://prom:9093 # The URL of the Alertmanager to send alerts (Prometheus, Mimir, etc.)<br><br>   querier:<br>      max_concurrent: 4<br><br>   storage:<br>      type: s3<br>      bucketNames:<br>        chunks: &quot;&lt;CHUNK BUCKET NAME&gt;&quot; # Your actual S3 bucket name (loki-aws-dev-chunks)<br>        ruler: &quot;&lt;RULER BUCKET NAME&gt;&quot; # Your actual S3 bucket name (loki-aws-dev-ruler)<br>        # admin: &quot;&lt;Insert s3 bucket name&gt;&quot; # Your actual S3 bucket name (loki-aws-dev-admin) - GEL customers only<br>      s3:<br>        region: &lt;S3 BUCKET REGION&gt; # eu-west-2<br>        #insecure: false<br>      # s3forcepathstyle: false<br><br>serviceAccount:<br> create: true<br> annotations:<br>   &quot;eks.amazonaws.com/role-arn&quot;: &quot;arn:aws:iam::&lt;Account ID&gt;:role/LokiServiceAccountRole&quot; # The service role you created<br><br>deploymentMode: Distributed<br><br>ingester:<br> replicas: 3<br> zoneAwareReplication:<br>  enabled: false<br><br>querier:<br> replicas: 3<br> maxUnavailable: 2<br><br>queryFrontend:<br> replicas: 2<br> maxUnavailable: 1<br><br>queryScheduler:<br> replicas: 2<br><br>distributor:<br> replicas: 3<br> maxUnavailable: 2<br>compactor:<br> replicas: 1<br><br>indexGateway:<br> replicas: 2<br> maxUnavailable: 1<br><br>ruler:<br> replicas: 1<br> maxUnavailable: 1<br><br><br># This exposes the Loki gateway so it can be written to and queried externaly<br>gateway:<br> service:<br>   type: LoadBalancer<br> basicAuth: <br>     enabled: true<br>     existingSecret: loki-basic-auth<br><br># Since we are using basic auth, we need to pass the username and password to the canary<br>lokiCanary:<br>  extraArgs:<br>    - -pass=$(LOKI_PASS)<br>    - -user=$(LOKI_USER)<br>  extraEnv:<br>    - name: LOKI_PASS<br>      valueFrom:<br>        secretKeyRef:<br>          name: canary-basic-auth<br>          key: password<br>    - name: LOKI_USER<br>      valueFrom:<br>        secretKeyRef:<br>          name: canary-basic-auth<br>          key: username<br><br># Enable minio for storage<br>minio:<br> enabled: false<br><br>backend:<br> replicas: 0<br>read:<br> replicas: 0<br>write:<br> replicas: 0<br><br>singleBinary:<br> replicas: 0</pre><blockquote><em>Make sure to replace the placeholders with your actual values.</em></blockquote><p>It is critical to define a valid values.yaml file for the Loki deployment. To remove the risk of misconfiguration, let’s break down the configuration options to keep in mind when deploying to AWS:</p><h4>Loki Config vs. Values Config:</h4><ul><li>The values.yaml file contains a section called loki, which contains a direct representation of the Loki configuration file.</li><li>This section defines the Loki configuration, including the schema, storage, and querier configuration.</li><li>The key configuration to focus on for chunks is the storage_config section, where you define the S3 bucket region and name. This tells Loki where to store the chunks.</li><li>The ruler section defines the configuration for the ruler, including the S3 bucket region and name. This tells Loki where to store the alert and recording rules.</li><li>For the full Loki configuration, refer to the <a href="https://grafana.com/docs/loki/latest/configure/?src=yt&amp;mdm=social&amp;cnt=description">Loki Configuration</a> documentation.</li></ul><h4>Storage:</h4><ul><li>Defines where the Helm chart stores data.</li><li>Set the type to s3 since we are using Amazon S3.</li><li>Configure the bucket names for the chunks and ruler to match the buckets created earlier.</li><li>The s3 section specifies the region of the bucket.</li></ul><h4>Service Account:</h4><ul><li>The serviceAccount section is used to define the IAM role for the Loki service account.</li><li>This is where the IAM role created earlier is linked.</li></ul><h4>Gateway:</h4><ul><li>Defines how the Loki gateway will be exposed.</li><li>We are using a LoadBalancer service type in this configuration.</li></ul><p>Now that you have created the values.yaml file, you can deploy Loki using the Helm chart.</p><ul><li>Deploy using the newly created values.yaml file:</li></ul><pre>helm install — values values.yaml loki grafana/loki -n loki — create-namespace</pre><blockquote><strong>It is important to create a namespace called </strong><strong>loki as our trust policy is set to allow the IAM role to be used by the </strong><strong>loki service account in the </strong><strong>loki namespace. This is configurable but make sure to update your service account.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FxFw7z0a-g_USWi6.png" /></figure><ul><li>Verify the deployment:</li></ul><pre>kubectl get pods -n loki</pre><p>You should see the pods are running.</p><pre>NAME                                    READY   STATUS    RESTARTS   AGE<br>loki-canary-crqpg                       1/1     Running   0          10m<br>loki-canary-hm26p                       1/1     Running   0          10m<br>loki-canary-v9wv9                       1/1     Running   0          10m<br>loki-chunks-cache-0                     2/2     Running   0          10m<br>loki-compactor-0                        1/1     Running   0          10m<br>loki-distributor-78ccdcc9b4-9wlhl       1/1     Running   0          10m<br>loki-distributor-78ccdcc9b4-km6j2       1/1     Running   0          10m<br>loki-distributor-78ccdcc9b4-ptwrb       1/1     Running   0          10m<br>loki-gateway-5f97f78755-hm6mx           1/1     Running   0          10m<br>loki-index-gateway-0                    1/1     Running   0          10m<br>loki-index-gateway-1                    1/1     Running   0          10m<br>loki-ingester-zone-a-0                  1/1     Running   0          10m<br>loki-ingester-zone-b-0                  1/1     Running   0          10m<br>loki-ingester-zone-c-0                  1/1     Running   0          10m<br>loki-querier-89d4ff448-4vr9b            1/1     Running   0          10m<br>loki-querier-89d4ff448-7nvrf            1/1     Running   0          10m<br>loki-querier-89d4ff448-q89kh            1/1     Running   0          10m<br>loki-query-frontend-678899db5-n5wc4     1/1     Running   0          10m<br>loki-query-frontend-678899db5-tf69b     1/1     Running   0          10m<br>loki-query-scheduler-7d666bf759-9xqb5   1/1     Running   0          10m<br>loki-query-scheduler-7d666bf759-kpb5q   1/1     Running   0          10m<br>loki-results-cache-0                    2/2     Running   0          10m<br>loki-ruler-0                            1/1     Running   0          10m</pre><h4>Find the Loki Gateway Service</h4><p>The Loki Gateway service is a LoadBalancer service that exposes the Loki gateway to the internet. This is where you will write logs to and query logs from. By default NGINX is used as the gateway.</p><p>To find the Loki Gateway service, run the following command:</p><pre>kubectl get svc -n loki</pre><p>You should see the Loki Gateway service with an external IP address. This is the address you will use to write to and query Loki.</p><pre>  NAME                             TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)              AGE<br>loki-gateway                     LoadBalancer   10.100.201.74    1111111111111111112222-xxxxxxxxxxxxxxxxxxxxxx.eu-west-2.elb.amazonaws.com   80:30707/TCP         46m</pre><blockquote>💡 Tip: <br>If Grafana is running inside the same Kubernetes cluster as Loki, you can configure the data source using the following URL:</blockquote><blockquote><a href="http://loki-gateway.loki.svc.cluster.local/">http://loki-gateway.loki.svc.cluster.local/</a></blockquote><h4>Step 5: Deploying Grafana and Adding Data Source</h4><p>If you prefer to deploy Grafana inside your EKS cluster using Helm Charts, here is a quick guide:</p><p>First, add the Grafana Helm repository and update:</p><pre>helm repo add grafana https://grafana.github.io/helm-charts <br>helm repo update</pre><p>Then install Grafana:</p><pre>helm upgrade - install grafana grafana/grafana \<br> - set adminPassword=&#39;YourStrongPassword&#39; \<br> - set service.type=LoadBalancer \<br> - namespace monitoring \<br> - create-namespace</pre><p>After deployment, you can access Grafana using the LoadBalancer endpoint and start configuring it by adding Loki as a data source.</p><p>After deployment:</p><ul><li>Access <strong>Grafana UI</strong>.</li><li>Configure <strong>Loki</strong> as a data source with <strong>Basic Authentication</strong>, using the credentials provided above.</li><li>Start querying and visualizing your backend application logs! ✌🏻</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ll6PUKIa6H04rvy4.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TJG5pTUTGtPfJfao.png" /></figure><h4>⚠️ Important Note:</h4><p>Loki defaults to running in multi-tenant mode. Multi-tenant mode is set in the configuration with auth_enabled: true. When configured with auth_enabled: false, Loki uses a single tenant. The X-Scope-OrgID header is not required in Loki API requests. The single tenant ID will be the string fake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*sFkKer5VSDEIIY5X.png" /></figure><p>So, we need to add the under the X-Scope-OrgID header under the &quot;Custom HTTP Headers&quot; section or add this to the values.yaml file:</p><pre>loki: <br>  auth_enabled: false</pre><h4>Step 6 (Bonus): Optimize Log Storage with S3 Lifecycle Policies</h4><p>As logs accumulate, storage costs can grow. AWS S3 Lifecycle Policies help optimize storage costs automatically.</p><p>For example:</p><ul><li>Move logs older than <strong>30 days</strong> to <strong>S3 Standard-IA</strong>.</li><li>Move logs older than <strong>90 days</strong> to <strong>S3 Glacier</strong>.</li><li>Delete logs after <strong>365 days</strong> if needed.</li></ul><p>Example JSON policy:</p><pre>{<br>  &quot;Rules&quot;: [<br>    {<br>      &quot;ID&quot;: &quot;MoveToIA&quot;,<br>      &quot;Prefix&quot;: &quot;backend-logs/&quot;,<br>      &quot;Status&quot;: &quot;Enabled&quot;,<br>      &quot;Transitions&quot;: [<br>        {<br>          &quot;Days&quot;: 30,<br>          &quot;StorageClass&quot;: &quot;STANDARD_IA&quot;<br>        },<br>        {<br>          &quot;Days&quot;: 90,<br>          &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>        }<br>      ],<br>      &quot;Expiration&quot;: {<br>        &quot;Days&quot;: 365<br>      }<br>    }<br>  ]<br>}</pre><p>You can set this up easily through the <strong>AWS Management Console</strong> or via <strong>IaC</strong> tools like <strong>Terraform</strong>.</p><h4>Conclusion</h4><p>By combining <strong>EKS</strong>, <strong>S3</strong>, <strong>Loki</strong>, <strong>Fluent Bit</strong> and <strong>Grafana</strong>, you can build a powerful and scalable game backend observability and log monitoring solution — without worrying about running your own heavy log management infrastructure. Additionally, with smart lifecycle policies, you ensure long-term sustainability and cost efficiency.</p><p>This approach lets game studios focus on building reliable, high-performance games while having deep insights into their backend systems.</p><p>References:</p><ul><li><a href="https://grafana.com/docs/loki/latest/setup/install/helm/deployment-guides/aws/?src=yt&amp;mdm=social&amp;cnt=description">Grafana Docs</a></li><li><a href="https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html">AWS EKS Docs</a></li><li><a href="https://docs.fluentbit.io/manual">Fluent Bit Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=115dc0c3e3db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clerion/game-backend-observability-and-monitoring-on-aws-115dc0c3e3db">Game Backend Observability and Monitoring on AWS</a> was originally published in <a href="https://medium.com/clerion">Clerion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSH into a Docker Container on AWS Fargate]]></title>
            <link>https://medium.com/clerion/ssh-into-a-docker-container-on-aws-fargate-1cf723b87c9b?source=rss-bc49e7be6206------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf723b87c9b</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Ata Ince]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 14:37:18 GMT</pubDate>
            <atom:updated>2025-04-16T15:10:00.959Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*d6yFsxBrvRBXHOolYobTZg@2x.png" /></figure><p>Setting up an SSH-accessible Docker container can be useful for debugging, remote management, and infrastructure prototyping. In this post, we’ll walk through how to:</p><ul><li><strong>Build a Docker image with SSH and Python</strong></li><li><strong>Push it to Amazon ECR</strong></li><li><strong>Deploy it serverlessly on AWS Fargate</strong></li><li><strong>Connect to it via SSH</strong></li></ul><h3>🏢 Step 1: Build the Docker Image</h3><p>We start by creating a Dockerfile that installs Python and an SSH server on an Ubuntu base image:</p><pre>FROM ubuntu:22.04<br># Install Python and OpenSSH<br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y python3 openssh-server &amp;&amp; \<br>    apt-get clean<br># Prepare SSH<br>RUN mkdir /var/run/sshd &amp;&amp; \<br>    sed -i &#39;s/#PermitRootLogin prohibit-password/PermitRootLogin without-password/&#39; /etc/ssh/sshd_config &amp;&amp; \<br>    mkdir -p /root/.ssh &amp;&amp; chmod 700 /root/.ssh<br># Set working directory<br>WORKDIR /app<br># Add content for web server<br>RUN echo &quot;Hello World&quot; &gt; index.html<br># Expose necessary ports<br>EXPOSE 80 22<br># Start SSH and HTTP servers<br>CMD echo &quot;$SSH_PUBLIC_KEY&quot; &gt; /root/.ssh/authorized_keys &amp;&amp; \<br>    chmod 600 /root/.ssh/authorized_keys &amp;&amp; \<br>    service ssh start &amp;&amp; \<br>    python3 -m http.server 80</pre><p>Build it locally:</p><pre>docker buildx build --platform linux/amd64 -t ubuntu-hello-ssh .</pre><h3>🍎 Note for Apple Silicon Users</h3><p>If you’re using a Mac with Apple Silicon (ARM-based architecture), and you want your container to run on AWS infrastructure (which typically uses <strong>x86_64/amd64</strong>), you must specify the platform during the build process:</p><pre>docker buildx build --platform linux/amd64 -t ubuntu-hello-ssh .</pre><p>However, be aware:</p><blockquote>⚠️ A Docker image built with — platform=linux/amd64 may not run <strong>locally</strong> on an Apple Silicon machine unless you’re using emulation. You’ll see errors like exec format error if you try to run the image directly.</blockquote><p>So, in most cases:</p><ul><li>✅ Build for amd64 if you’re planning to <strong>deploy to AWS</strong></li><li>✅ Build for arm64 if you’re testing <strong>locally</strong> on Apple Silicon</li></ul><p>You can even build <strong>multi-arch images</strong> using Docker Buildx and — platform=linux/amd64,linux/arm64 for maximum compatibility.</p><h3>📤 Step 2: Pushing the Docker Image to Amazon ECR</h3><p>Now that your Docker image is built and working locally, let’s upload it to <strong>Amazon Elastic Container Registry (ECR)</strong>. This will allow us to later deploy it on AWS Fargate.</p><h4>🛠 Create a Private Repository</h4><p>First, create a private repository in the AWS Console.<br>Go to <strong>Amazon ECR → Private Registry → Create repository</strong>, give it a name (e.g., ssh-demo-repo), keep the default settings, and hit <strong>Create</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rR5kaVPj5tUCIf-RyTWZ6A.png" /></figure><h4>🔐 Authenticate Docker with ECR</h4><p>Use the following command to authenticate your Docker client with ECR:</p><pre>aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin &lt;your-account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com</pre><blockquote><em>Replace </em><em>&lt;your-account-id&gt; with your actual AWS Account ID.</em></blockquote><h4>🏷️ Tag the Existing Image</h4><p>Since your Docker image is already built, you just need to tag it with your ECR repository URI:</p><pre>docker tag ubuntu-hello-ssh:latest &lt;your-account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com/ssh-demo-repo:latest</pre><h4>🚀 Push the Image to ECR</h4><p>Push the image using:</p><pre>docker push &lt;your-account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com/ssh-demo-repo:latest</pre><p>Once pushed, your image will appear in the ECR console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zod6JOuurH9O98p7arBpyg.png" /></figure><h3>🚀 Step 3: Create an ECS Cluster</h3><p>Create a new cluster in the <strong>Amazon ECS Console</strong>:</p><ul><li><strong>Name:</strong> ssh-demo-cluster</li><li><strong>Infrastructure:</strong> AWS Fargate (serverless)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P25xGnSrbGJB3SeerZ2CCg.png" /></figure><h3>📊 Step 4: Define the Task Definition</h3><p>In the ECS Console:</p><ul><li>Go to <strong>Task Definitions</strong></li><li>Click <strong>Create new task definition with JSON</strong></li></ul><pre>{<br>  &quot;family&quot;: &quot;ssh-demo-task&quot;,<br>  &quot;networkMode&quot;: &quot;awsvpc&quot;,<br>  &quot;requiresCompatibilities&quot;: [&quot;FARGATE&quot;],<br>  &quot;cpu&quot;: &quot;256&quot;,<br>  &quot;memory&quot;: &quot;512&quot;,<br>  &quot;containerDefinitions&quot;: [<br>    {<br>      &quot;name&quot;: &quot;ssh-demo-container&quot;,<br>      &quot;image&quot;: &quot;&lt;your-account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com/ssh-demo-repo:latest&quot;,<br>      &quot;portMappings&quot;: [<br>        {<br>          &quot;containerPort&quot;: 80,<br>          &quot;protocol&quot;: &quot;tcp&quot;<br>        },<br>        {<br>          &quot;containerPort&quot;: 22,<br>          &quot;protocol&quot;: &quot;tcp&quot;<br>        }<br>      ],<br>      &quot;environment&quot;: [<br>        {<br>          &quot;name&quot;: &quot;SSH_PUBLIC_KEY&quot;,<br>          &quot;value&quot;: &quot;ssh-rsa AAAAB3...your-public-key-here... user@host&quot;<br>        }<br>      ],<br>      &quot;essential&quot;: true<br>    }<br>  ],<br>  &quot;executionRoleArn&quot;: &quot;arn:aws:iam::&lt;your-account-id&gt;:role/ecsTaskExecutionRole&quot;<br>}</pre><blockquote><em>Replace </em><strong><em>&lt;your-account-id&gt;</em></strong><em> and the </em><strong><em>SSH_PUBLIC_KEY</em></strong><em> value with your own.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ziAG6k5vmxdyH5FBjFcLg.png" /></figure><blockquote><em>🔐 For production environments, replace the environment block with secrets to inject sensitive variables securely via </em><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html"><em>AWS Secrets Manager</em></a><em>.</em></blockquote><h3>🌐 Step 5: Create a Fargate Service</h3><p>Go to your ECS Cluster, click <strong>Services → Create</strong>, then:</p><ul><li><strong>Launch type:</strong> Fargate</li><li><strong>Task definition:</strong> ssh-demo-task</li><li><strong>Service name:</strong> ssh-demo-container</li><li><strong>Number of tasks:</strong> 1</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zod6JOuurH9O98p7arBpyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vfELifD8EJWmEZequII1Qw.png" /></figure><p>Configure networking:</p><ul><li><strong>Select a public subnet</strong></li><li><strong>Enable public IP assignment</strong></li><li><strong>Use a security group allowing ports 80 and 22 (SSH only from your IP)</strong></li></ul><h3>🛡️ Step 6: Connect via SSH</h3><p>Once the task is running:</p><ul><li>Go to <strong>Tasks → ENI → Public IP</strong></li><li>SSH into your container:</li></ul><pre>ssh -i ~/.ssh/id_rsa root@&lt;public-ip&gt; -p 22 -o StrictHostKeyChecking=no</pre><p>You should be inside your Fargate-hosted Ubuntu container!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*UeeUQmgBCau7PF0ewp1y0A.png" /></figure><h3>🔒 Bonus: Use AWS Secrets Manager for Key Injection</h3><p>Instead of passing your key as an environment variable, use a more secure method:</p><ul><li>Store it in <strong>AWS Secrets Manager</strong>:</li><li>Reference it in your Task Definition JSON:</li></ul><pre>&quot;secrets&quot;: [<br>  {<br>    &quot;name&quot;: &quot;SSH_PUBLIC_KEY&quot;,<br>    &quot;valueFrom&quot;: &quot;arn:aws:secretsmanager:eu-central-1:&lt;your-account-id&gt;:secret:ssh-public-key-xxxxxx&quot;<br>  }<br>]</pre><p>This keeps your secrets encrypted and never exposed in plaintext.</p><h3>🌟 Summary</h3><blockquote><strong><em>✅ Built a Docker image with SSH and Python</em></strong></blockquote><blockquote><strong><em>✅ Pushed it to Amazon ECR</em></strong></blockquote><blockquote><strong><em>✅ Deployed it using ECS Fargate</em></strong></blockquote><blockquote><strong><em>✅ Connected to it securely via SSH</em></strong></blockquote><blockquote><strong><em>✅ Explored secure ways to inject credentials</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf723b87c9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clerion/ssh-into-a-docker-container-on-aws-fargate-1cf723b87c9b">SSH into a Docker Container on AWS Fargate</a> was originally published in <a href="https://medium.com/clerion">Clerion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>