Install Observe Agent using Ansible

Install the Observe Agent

Before you begin, install Ansible on your control node.

Install the observe-agent package. You’ll need to first add the Observe debian repository to your trusted depositories in your sources.list.d file. Create package.yaml under /etc/ansible/roles/agent/tasks/.

- name : Install Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: add observe-agent apt source
      ansible.builtin.copy:
        dest: /etc/apt/sources.list.d/observeinc.list
        mode: 0644
        content: |
          deb [trusted=yes] https://repo.observeinc.com/apt/ /
    - name: install observe-agent package
      ansible.builtin.apt:
        install_recommends: no
        name: observe-agent
        state: latest
        update_cache: yes   

Use ansible-playbook to install the Observe Agent with package.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook -i /etc/ansible/hosts/my.aws_ec2.ini --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/package.yaml

PLAY [Observe Agent Getting Started Playbook] ******************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [add observe-agent apt source] ****************************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

TASK [install observe-agent package] ***************************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

PLAY RECAP *****************************************************************************************************************************************************************************************
ansible-managed-node-1 : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansible-managed-node-2 : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Install the observe-agent package. You’ll need to first add the Observe yum repository to your trusted repositories in your yum.repos.d folder. Create package.yaml under /etc/ansible/roles/agent/tasks/.

- name : Install Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: add observe-agent yum source
      ansible.builtin.yum_repository:
        name: observe
        description: Gemfury Private Repo
        baseurl: https://yum.fury.io/observeinc/
        mode: 0644
    - name: install observe-agent package
      yum:
        name: observe-agent
        state: latest
        update_cache: yes
        disable_gpg_check: yes

Use ansible-playbook to install the Observe Agent with package.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/package.yaml

PLAY [Install Observe Agent] ************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [add observe-agent yum source] *****************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [install observe-agent package] ****************************************************************************************************************
changed: [54.202.68.91]
changed: [35.87.95.246]

PLAY RECAP ******************************************************************************************************************************************
35.87.95.246               : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
54.202.68.91               : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Configure the Observe Agent

Create config.yaml under /etc/ansible/roles/agent/tasks/.

- name : Config Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: install observe-agent.yaml
      ansible.builtin.template:
        src: ../templates/observe-agent.yaml.j2
        dest: /etc/observe-agent/observe-agent.yaml
        owner: root
        group: observe-agent
        mode: 0640

Create observe-agent.yaml.j2 under /etc/ansible/roles/agent/templates. Replace ${OBSERVE_TOKEN} (your instance’s token) and ${OBSERVE_COLLECTION_ENDPOINT} (your instance’s collection endpoint) on each host. For more information on configuring the agent, see Configuration.

# Observe data token (ex: a1b2c3d4e5f6g7h8i9k0:l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6)
token: "${OBSERVE_TOKEN}"

# Target Observe collection url (ex: https://123456789012.collect.observeinc.com/)
observe_url: "${OBSERVE_COLLECTION_ENDPOINT}"

host_monitoring:
  enabled: true
  logs: 
    enabled: true
  metrics:
    enabled: true

# otel_config_overrides:
#   exporters:
#     debug:
#       verbosity: detailed
#       sampling_initial: 5
#       sampling_thereafter: 200
#   service:
#     pipelines:
#       # This will override the existing metrics/host_monitoring pipeline and output to stdout debug instead
#       metrics/host_monitoring:
#         receivers: [hostmetrics/host-monitoring]
#         processors: [memory_limiter]
#         exporters: [debug]

Use ansible-playbook to configure the Observe Agent with config.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook -i /etc/ansible/hosts/my.aws_ec2.ini --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/config.yaml

PLAY [Config Observe Agent] ************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [install observe-agent.yaml] ******************************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

PLAY RECAP *****************************************************************************************************************************************************************************************
ansible-managed-node-1 : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansible-managed-node-2 : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Create config.yaml under /etc/ansible/roles/agent/tasks/.

- name : Config Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: install observe-agent.yaml
      ansible.builtin.template:
        src: ../templates/observe-agent.yaml.j2
        dest: /etc/observe-agent/observe-agent.yaml
        owner: root
        group: observe-agent
        mode: 0640

Create observe-agent.yaml.j2 under /etc/ansible/roles/agent/templates. Replace ${OBSERVE_TOKEN} (your instance’s token) and ${OBSERVE_COLLECTION_ENDPOINT} (your instance’s collection endpoint) on each host. For more information on configuring the agent, see Configuration.

# Observe data token (ex: a1b2c3d4e5f6g7h8i9k0:l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6)
token: "${OBSERVE_TOKEN}"

# Target Observe collection url (ex: https://123456789012.collect.observeinc.com/)
observe_url: "${OBSERVE_COLLECTION_ENDPOINT}"

host_monitoring:
  enabled: true
  logs: 
    enabled: true
  metrics:
    enabled: true

# otel_config_overrides:
#   exporters:
#     debug:
#       verbosity: detailed
#       sampling_initial: 5
#       sampling_thereafter: 200
#   service:
#     pipelines:
#       # This will override the existing metrics/host_monitoring pipeline and output to stdout debug instead
#       metrics/host_monitoring:
#         receivers: [hostmetrics/host-monitoring]
#         processors: [memory_limiter]
#         exporters: [debug]

Use ansible-playbook to configure the Observe Agent with config.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/config.yaml

PLAY [Config Observe Agent] *************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [install observe-agent.yaml] *******************************************************************************************************************
changed: [54.202.68.91]
changed: [35.87.95.246]

PLAY RECAP ******************************************************************************************************************************************
35.87.95.246               : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
54.202.68.91               : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Start the Observe Agent

Create enable.yaml under /etc/ansible/roles/agent/tasks/.

- name : Start Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: enable observe-agent
      ansible.builtin.systemd_service:
        enabled: true
        name: observe-agent
        state: started 

Use ansible-playbook to start the Observe Agent with enable.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook -i /etc/ansible/hosts/my.aws_ec2.ini --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/enable.yaml

PLAY [Start Observe Agent] *************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [Enable observe-agent] ************************************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

PLAY RECAP *****************************************************************************************************************************************************************************************
ansible-managed-node-1 : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansible-managed-node-2 : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Create enable.yaml under /etc/ansible/roles/agent/tasks/.

- name : Start Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: enable observe-agent
      systemd:
        enabled: true
        name: observe-agent
        state: started

Use ansible-playbook to start the Observe Agent with enable.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/enable.yaml

PLAY [Start Observe Agent] **************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [enable observe-agent] *************************************************************************************************************************
changed: [35.87.95.246]
changed: [54.202.68.91]

PLAY RECAP ******************************************************************************************************************************************
35.87.95.246               : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
54.202.68.91               : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Configure application instrumentation

Once the Observe Agent is up and running on a Linux host, you can configure your application running on the same Linux host to send telemetry data to the Observe Agent using one of the following addresses:

  • OTLP/HTTP endpoint: http://localhost:4318

  • OTLP/gRPC endpoint: http://localhost:4317

Uninstall the Observe Agent

Create uninstall.yaml under /etc/ansible/roles/agent/tasks/.

- name : Uninstall Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: stop observe-agent
      ansible.builtin.systemd_service:
        name: observe-agent
        state: stopped
    - name: purge observe-agent
      ansible.builtin.apt:
        name: observe-agent
        state: absent
        purge: true 

Use ansible-playbook to start the Observe Agent with uninstall.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook -i /etc/ansible/hosts/my.aws_ec2.ini --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/uninstall.yaml

PLAY [Uninstall Observe Agent] *****************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [stop observe-agent] **********************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [purge observe-agent] *********************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

PLAY RECAP *************************************************************************************************************************************************************************
ansible-managed-node-1 : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansible-managed-node-2 : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Create uninstall.yaml under /etc/ansible/roles/agent/tasks/.

- name : Uninstall Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: stop observe-agent
      systemd:
        name: observe-agent
        state: stopped
    - name: purge observe-agent
      yum:
        name: observe-agent
        state: absent

Use ansible-playbook to start the Observe Agent with uninstall.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/uninstall.yaml

PLAY [Uninstall Observe Agent] **********************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [stop observe-agent] ***************************************************************************************************************************
ok: [54.202.68.91]
ok: [35.87.95.246]

TASK [purge observe-agent] **************************************************************************************************************************
changed: [54.202.68.91]
changed: [35.87.95.246]

PLAY RECAP ******************************************************************************************************************************************
35.87.95.246               : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
54.202.68.91               : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Upgrade the Observe Agent

Create upgrade.yaml under /etc/ansible/roles/agent/tasks/.

- name : Upgrade Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: upgrade observe-agent package
      ansible.builtin.apt:
        install_recommends: no
        name: observe-agent
        update_cache: yes
        only_upgrade: true
    - name: restart observe-agent
      ansible.builtin.systemd_service:
        enabled: true
        state: restarted
        name: observe-agent

Use ansible-playbook to upgrade and restart the Observe Agent with upgrade.yaml. Your ansible-playbook could be similar to the following one.

$ ansible-playbook -i /etc/ansible/hosts/my.aws_ec2.ini --private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/upgrade.yaml

PLAY [Upgrade Observe Agent] *******************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [upgrade observe-agent package] ***********************************************************************************************************************************************
ok: [ansible-managed-node-1]
ok: [ansible-managed-node-2]

TASK [restart observe-agent] *******************************************************************************************************************************************************
changed: [ansible-managed-node-1]
changed: [ansible-managed-node-2]

PLAY RECAP *************************************************************************************************************************************************************************
ansible-managed-node-1 : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansible-managed-node-2 : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

Create upgrade.yaml under /etc/ansible/roles/agent/tasks/.

- name : Upgrade Observe Agent
  hosts: all
  become: yes
  tasks:
    - name: upgrade observe-agent package
      yum:
        name: observe-agent
        disable_gpg_check: yes
        state: latest
        update_cache: yes
    - name: restart observe-agent
      systemd:
        enabled: true
        name: observe-agent
        state: restarted

Use ansible-playbook to upgrade and restart the Observe Agent with upgrade.yaml. Your ansible-playbook could be similar to the following one.


$ ansible-playbook –private-key observe-agent-test.pem /etc/ansible/roles/agent/tasks/upgrade.yaml

PLAY [Upgrade Observe Agent] *****************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************** ok: [35.87.95.246] ok: [54.202.68.91]

TASK [upgrade observe-agent package] ********************************************************************************************************************************************************************************************* ok: [54.202.68.91] ok: [35.87.95.246]

TASK [restart observe-agent] ***************************************************************************************************************************************************************************************************** changed: [54.202.68.91] changed: [35.87.95.246]

PLAY RECAP *********************************************************************************************************************************************************************************************************************** 35.87.95.246 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 54.202.68.91 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0