# OpenTelemetry custom logs

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fintegrations%2Fdata-ingestion%2Fopentelemetry-custom-logs.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fintegrations%2Fdata-ingestion%2Fopentelemetry-custom-logs.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

Send your **custom logs** to Coralogix using our OpenTelemetry-compatible endpoint.

## Overview[​](#overview "Direct link to Overview")

Custom logs can be delivered directly to the Coralogix OpenTelemetry-compatible <!-- -->ingress.:443<!-- --> endpoint using any gRPC client or [OpenTelemetry SDKs](https://opentelemetry.io/docs/concepts/sdk-configuration/).

The examples below guide you using gRPCurl and OpenTelemetry Java SDK.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

If you are sending us your data using gRPCurl, you are required to have [Git](https://git-scm.com/) and [gRPCurl](https://github.com/fullstorydev/grpcurl) installed.

## Data model[​](#data-model "Direct link to Data model")

The custom logs API implementation is based on the OpenTelemetry [logging specification](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/logs/v1/logs.proto). This ensures that our logging implementation adheres to industry best practices and can seamlessly integrate with other components and tools in the OpenTelemetry ecosystem.

### Example log[​](#example-log "Direct link to Example log")

```
{

  "resource_logs": [

    {

      "resource": {

        "attributes": [

          {

            "key": "cx.application.name",

            "value": {

              "string_value": "my-test-application"

            }

          },

          {

            "key": "cx.subsystem.name",

            "value": {

              "string_value": "my-test-subsystem"

            }

          }

        ]

      },

      "scope_logs": [

        {

          "scope": {

            "name": "test"

          },

          "log_records": [

            {

              "time_unix_nano": "1665989944490035000",

              "severity_number": "SEVERITY_NUMBER_WARN",

              "severity_text": "WARN",

              "body": {

                "string_value": "Test log message"

              }

            }

          ]

        }

      ]

    }

  ]

}
```

## Sending data with gRPCurl[​](#sending-data-with-grpcurl "Direct link to Sending data with gRPCurl")

gRPC is a modern way of calling APIs on top of HTTP/2. Similar to cURL, [gRPCurl](https://github.com/fullstorydev/grpcurl) is a command-line tool used to communicate with gRPC services.

Coralogix supports OTLP/gRPC and OTLP/HTTP (binary protobuf or JSON payloads) for its custom logs endpoint.

Assuming the example in the data model is saved as `logs.json`, use the following command to send your data to Coralogix:

```
# Clone OpenTelemetry protobuf definitions

git clone https://github.com/open-telemetry/opentelemetry-proto.git

# Send logs to Coralogix 

grpcurl -v -d @ \

  -rpc-header 'Authorization: Bearer <send-your-data-api-key>' \

  -proto opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto \

  -import-path opentelemetry-proto \

  ingress.eu2.coralogix.com:443 \

  opentelemetry.proto.collector.logs.v1.LogsService/Export \

  < logs.json
```

**Notes**:

* For `<open-telemetry-endpoint>`, select the <!-- -->ingress.:443<!-- --> endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/docs/user-guides/account-management/account-settings/coralogix-domain/.md) using the domain selector at the top of the page.

* For the `<send-your-data-api-key>`, input your Coralogix [Send-Your-Data API key](https://coralogix.com/docs/docs/user-guides/account-management/api-keys/send-your-data-api-key/.md).

* Set the `time_unix_nano` in the `logs.json` to a timestamp that is within the last 24 hours.

## Sending data using the OpenTelemetry Java SDK[​](#sending-data-using-the-opentelemetry-java-sdk "Direct link to Sending data using the OpenTelemetry Java SDK")

The example below guides you using OpenTelemetry Java SDK to send your custom logs to Coralogix. Others [SDKs](https://opentelemetry.io/docs/concepts/sdk-configuration/) may also be used.

**STEP 1**. Add to your maven pom.xml the following libraries:

```
<dependency>

	<groupId>io.opentelemetry</groupId>

	<artifactId>opentelemetry-sdk-logs</artifactId>

  <version><!-- put a recent version of opentelemetry sdk here --><version>

</dependency>

<dependency>

	<groupId>io.opentelemetry</groupId>

	<artifactId>opentelemetry-exporter-otlp-logs</artifactId>

  <version><!-- put a recent version of opentelemetry sdk here --><version>

</dependency>
```

**STEP 2**. Use the following code snippet to create and report a span:

```
SdkLoggerProvider loggerProvider =

      SdkLoggerProvider.builder()

        .addLogRecordProcessor(BatchLogRecordProcessor.builder(

          OtlpGrpcLogRecordExporter.builder()

            .setEndpoint("ingress.eu2.coralogix.com:443")

            .addHeader("Authorization", "Bearer <send-your-data-api-key>")

            .build()

        ).build())

        .setResource(Resource.create(Attributes.of(

          AttributeKey.stringKey("cx.application.name"), "my-test-application",

          AttributeKey.stringKey("cx.subsystem.name"), "my-test-subsystem")))

        .build();



    Logger logger = loggerProvider.loggerBuilder("test").build();



    logger.logRecordBuilder()

      .setSeverity(Severity.WARN)

      .setSeverityText("WARN")

      .setBody("Test log message")

      .emit();



    loggerProvider.forceFlush();
```

## Limits & Quotas[​](#limits--quotas "Direct link to Limits & Quotas")

Coralogix places a **hard limit of 10MB** of data to our OpenTelemetry [endpoints](https://coralogix.com/docs/docs/integrations/coralogix-endpoints/.md), with a **recommendation of 2MB**.

Limits apply to single requests, regardless of timespan.

## Additional Resources[​](#additional-resources "Direct link to Additional Resources")

|               |                                                                                             |
| ------------- | ------------------------------------------------------------------------------------------- |
| Documentation | [Coralogix Endpoints](https://coralogix.com/docs/docs/integrations/coralogix-endpoints/.md) |
