[Yandex Cloud documentation](../../index.md) > [Monium](../index.md) > [Data delivery](index.md) > Fluent Bit > Example for a Java demo application with Fluent Bit

# Setting up a demo Java app and collecting telemetry

## Getting started {#before-you-begin}

Sign up for Yandex Cloud and create a [billing account](../../billing/concepts/billing-account.md):
1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud or create a new account.
1. On the **[Yandex Cloud Billing](https://center.yandex.cloud/billing/accounts)** page, make sure you have a billing account linked and it has the `ACTIVE` or `TRIAL_ACTIVE` [status](../../billing/concepts/billing-account-statuses.md). If you do not have a billing account, [create one](../../billing/quickstart/index.md) and [link](../../billing/operations/pin-cloud.md) a cloud to it.

If you have an active billing account, you can create or select a [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) for your infrastructure on the [cloud page](https://console.yandex.cloud/cloud).

[Learn more about clouds and folders here](../../resource-manager/concepts/resources-hierarchy.md).


## Setting up a demo app and telemetry delivery {#pet-clinic-fluentbit}

In this example, you will install [Spring PetClinic](https://github.com/spring-projects/spring-petclinic) and set up sending telemetry data to Monium via Fluent Bit.

{% list tabs group=instructions %}

- Your infrastructure {#user-infrastructure}

  1. Install [Git](https://git-scm.com/install/) and [Java](https://jdk.java.net/) suitable for your OS. Here is an example:

     ```bash
     sudo apt update
     sudo apt install -y git openjdk-17-jdk
     ```

  1. Install [Fluent Bit](https://docs.fluentbit.io/fluent-bit/v/4.0/installation/getting-started-with-fluent-bit) 4.0 or higher.

  1. Set these environment variables:

     ```bash
     export MONIUM_PROJECT=<project_ID>
     export MONIUM_API_KEY=<API_key>
     ```

  1. Create a configuration file, e.g., `fluent-bit.yaml`. Use the [Fluent Bit settings](fluentbit.md#configure) section configuration. Example for gRPC:

     ```yaml
     pipeline:
       inputs:
         - name: opentelemetry
           listen: 127.0.0.1
           port: 4318

       outputs:
         - name: opentelemetry
           match: "*"
           host: ingest.monium.yandex.cloud
           port: 443
           tls: on
           compress: zstd
           grpc: on
           header:
             - Authorization Api-Key ${MONIUM_API_KEY}
             - x-monium-project ${MONIUM_PROJECT}
     ```

  1. Run Fluent Bit:

     ```bash
     fluent-bit -c fluent-bit.yaml
     ```

     Fluent Bit will start receiving telemetry over OTLP at `127.0.0.1:4318` (HTTP).

  1. Download and build Spring PetClinic:

     ```bash
     git clone https://github.com/spring-projects/spring-petclinic
     cd spring-petclinic
     ./mvnw -DskipTests package
     ```

  1. Download the OpenTelemetry Java agent:

     ```bash
     curl -L -o opentelemetry-javaagent.jar \
       https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
     ```

  1. Run the application with the Java agent. The telemetry will go to Fluent Bit port 4318. Do not specify `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE="delta"`: when transferred via Fluent Bit, delta metrics cannot be processed correctly.

     ```bash
     OTEL_SERVICE_NAME=spring-petclinic \
     OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE="cumulative" \
     java -javaagent:./opentelemetry-javaagent.jar -jar target/*.jar
     ```

  1. Open Spring PetClinic at `http://localhost:8080` and simulate user actions.

{% endlist %}

## Viewing telemetry in Monium {#view-telemetry}

{% list tabs group=instructions %}

- Monium UI {#console}

  1. On the [Monium](https://monium.yandex.cloud) home page, select a data type section on the left:

      {% list tabs group=monium_telemetry_type %}

      - Metrics {#metrics}

        1. At the top, set the data search time period on the timeline.
        1. In the search bar, enter a query to search for telemetry data:
        
            * `project = <project_ID>`: Select the project specified in `x-monium-project` of the application's telemetry transmission configuration.
            
                This may be a cloud (`cloud__<cloud_ID>`) or folder (`folder__<folder_ID>`) project, or another [project](project.md#project-create).
            * `cluster = <cluster_name>`: Select the name of the installation that runs your application. If no cluster is specified, `cluster = default` is used.
            * `service = <service_name>`: Name of your application or service. You can use the `OTEL_SERVICE_NAME` environment variable to provide it.
            
              If you do not see the required labels in the suggestions, you can enter them manually. However, the system most likely has not received data with these labels. See [Data delivery troubleshooting](troubleshooting.md) for possible solutions.
        
        1. Click **Execute query** or **Execute**.
        
            The page will show data that matches the query.

        ![image](../../_assets/monium/petclinic-metrics.png)

        More on [metrics](../metrics/metric-explorer.md).

      - Logs {#logs}

        1. At the top, set the data search time period on the timeline.
        1. In the search bar, enter a query to search for telemetry data:
        
            * `project = <project_ID>`: Select the project specified in `x-monium-project` of the application's telemetry transmission configuration.
            
                This may be a cloud (`cloud__<cloud_ID>`) or folder (`folder__<folder_ID>`) project, or another [project](project.md#project-create).
            * `cluster = <cluster_name>`: Select the name of the installation that runs your application. If no cluster is specified, `cluster = default` is used.
            * `service = <service_name>`: Name of your application or service. You can use the `OTEL_SERVICE_NAME` environment variable to provide it.
            
              If you do not see the required labels in the suggestions, you can enter them manually. However, the system most likely has not received data with these labels. See [Data delivery troubleshooting](troubleshooting.md) for possible solutions.
        
        1. Click **Execute query** or **Execute**.
        
            The page will show data that matches the query.

        ![image](../../_assets/monium/petclinic-logs.png)

        More on [logs](../logs/logs-explorer.md).

      - Traces {#traces}

        1. At the top, set the data search time period on the timeline.
        1. In the search bar, enter a query to search for telemetry data:
        
            * `project = <project_ID>`: Select the project specified in `x-monium-project` of the application's telemetry transmission configuration.
            
                This may be a cloud (`cloud__<cloud_ID>`) or folder (`folder__<folder_ID>`) project, or another [project](project.md#project-create).
            * `cluster = <cluster_name>`: Select the name of the installation that runs your application. If no cluster is specified, `cluster = default` is used.
            * `service = <service_name>`: Name of your application or service. You can use the `OTEL_SERVICE_NAME` environment variable to provide it.
            
              If you do not see the required labels in the suggestions, you can enter them manually. However, the system most likely has not received data with these labels. See [Data delivery troubleshooting](troubleshooting.md) for possible solutions.
        
        1. Click **Execute query** or **Execute**.
        
            The page will show data that matches the query.

        ![image](../../_assets/monium/petclinic-traces.png)

        More on [traces](../traces/operations/traces-explorer.md).

      {% endlist %}

  1. To view information about the data shard, select **Shards** on the left and then, the shard with your service name.

{% endlist %}