> For the complete documentation index, see [llms.txt](https://cocktailcloud.gitbook.io/cocktail-cloud-online-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cocktailcloud.gitbook.io/cocktail-cloud-online-en/log-service/installation/install-log-service.md).

# Install Log Service

Log Service uses 'OpenSearch' to provide log storage and an API server to communicate with Cocktail Dashboard.

{% hint style="info" %}
Before installing the log service, 'cert-manager' and 'nginx' require pre-installation.
{% endhint %}

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2Fp8xDTTDefQ2zMxWKs3uL%2Fimage.png?alt=media&amp;token=65bcd64a-be77-4d46-af04-eb4436836d04" alt=""><figcaption></figcaption></figure>

## 1. Distribution Addon

1\) Infrastructure - Clusters - Addon List - Click the "Deploy" button and click the "Deploy" button for 'cocktail-log-service' in the list.

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2Fx6yzGrLUxD6h8Vzh0m3s%2Fimage.png?alt=media&amp;token=9eaa6c7a-15a2-4b94-931a-08dc9f194c1f" alt=""><figcaption></figcaption></figure>

2\) Check the settings according to your environment and click the Deploy button to deploy the Addon.

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2FWLklMP8uYWIiCcoALmhM%2Fimage.png?alt=media&amp;token=f90742d6-19d7-478d-83ae-439f1b961822" alt=""><figcaption></figcaption></figure>

**`Gateway Service Mode`** :  Log service gateway type (Ingress, LoadBalancer)

***

\[If Gateway Service Mode is set to Ingress]

**`Gateway Access URL`** :   DNS to access log service through Ingress

**`URL Type`** : Cluster HostAliases type (PublicDNS or HostAliases)

**`Host Ip`** : (If URL Type is 'HostAliases') LB IP (or node IP) that can access the cluster from outside

{% hint style="success" %}
When accessing the log service from the dashboard or collecting logs from log-agent, connect the Host IP to the Log Access URL.
{% endhint %}

**`Enable OpenSearch Dashboard`** : Use or not 'Opensearch Dashboard'

***

\[If Gateway Service Mode is set to LoadBalancer]

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2FWwqDxMfrYkdmywhlkn0X%2Fimage.png?alt=media&amp;token=47da07fd-6607-45ca-8b6e-8c38022fe7ca" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Clusters created through provisioning can only be set to '**Enable OpenSearch Dashboard'**.
{% endhint %}

3\) Check the deployment status and if the status is 'Running', confirm that the deployment has been completed successfully.

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2FZaQUanOfhMSQFGIoUjVi%2Fimage.png?alt=media&amp;token=473b773d-caa5-4f86-a05e-04ee9dba4647" alt=""><figcaption></figcaption></figure>

**`If the status is 'pending' when deployed`**

{% embed url="<https://cocktailcloud.gitbook.io/cocktail-cloud-online-en/log-service/troubleshooting#install-error>" %}

4\) Create a job in the namespace where the log service is installed.

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2FzXwC3GctgliubZLJSErv%2Fimage.png?alt=media&amp;token=d0aa1ee1-107e-4bc7-ba85-781939f60518" alt=""><figcaption></figcaption></figure>

Create a Job that creates policies for each container log, cluster audit log, and application log collected by Opensearch.

<figure><img src="https://4196990571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL5As9l8R3RbLkQd6XsfL%2Fuploads%2F1R96LYAXW9AiqtnX2U2k%2Fimage.png?alt=media&amp;token=a660933c-b75d-44e1-8d9e-99a6f35c942f" alt=""><figcaption></figcaption></figure>

```yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: policy-generate
  namespace: cocktail-logs
spec:
  ttlSecondsAfterFinished: 600
  template:
    spec:
      containers:
        - image: [registry address]/library/cocktail-auto-injector:1.0.0-release.20240425
          imagePullPolicy: Always
          command:
            - /bin/sh
            - -c
            - sh /auto/service/gen.sh -H opensearch-cluster-master.cocktail-logs -c 30d -u 100d -a 30d -m run
          name: gen
      restartPolicy: Never
  backoffLimit: 0
```

**`registry address`** :  Please contact our technical team.

If you create a job according to the settings above, container logs have a storage period of **30 days**, cluster audit logs have a storage period of **56 days**, and application logs have a storage period of **1 year**.

{% hint style="info" %}
Storage period settings can be modified in 'OpenSearch Dashboard'.
{% endhint %}
