Skip to content

Commit

Permalink
Merge branch 'master' into rca-to-agent-dec23
Browse files Browse the repository at this point in the history
  • Loading branch information
Simplychee authored Jan 1, 2025
2 parents b824e66 + a7b51b9 commit 907b739
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 184 deletions.
2 changes: 1 addition & 1 deletion docs/shipping/AWS/aws-ec2.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ service:
exporters: [prometheusremotewrite]
telemetry:
logs:
level: "debug"
level: "info"
metrics:
address: localhost:8888
```
Expand Down
2 changes: 1 addition & 1 deletion docs/shipping/AWS/aws-ecs-fargate.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ service:
exporters: [ prometheusremotewrite ]
telemetry:
logs:
level: "debug"
level: "info"
```
### AWS::Lambda::Function
The `logzioFirehoseSubscriptionFiltersFunction` Lambda function is designed to handle the process of filtering log data for Logz.io, and add and remove cloudwatch logs subscription filters
Expand Down
8 changes: 4 additions & 4 deletions docs/shipping/AWS/aws-lambda-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ This command overwrites the existing function configuration. If you already have
| Placeholder | Description | Required/Default|
|---|---|---|
| `<<FUNCTION-NAME>>` | Name of the Lambda Function you want to monitor. |Required|
| `<<LAYERS>>` | A space-separated list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version. For the ARN, see the [**ARNs** table]({@include: ../../_include/log-shipping/lambda-xtension-tablink.md}) | |
| `<<ENV-VARS>>` | Key-value pairs containing environment variables that are accessible from function code during execution. Should appear in the following format: `KeyName1=string,KeyName2=string`. For a list of all the environment variables for the extension, see the [**Lambda environment variables** table]{@include: ../../_include/log-shipping/lambda-xtension-tablink-indox.html} | |
| `<<LAYERS>>` | A space-separated list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version. For the ARN, see the [**ARNs** table](https://docs.logz.io/docs/shipping/aws/lambda-extensions/#arns) | |
| `<<ENV-VARS>>` | Key-value pairs containing environment variables that are accessible from function code during execution. Should appear in the following format: `KeyName1=string,KeyName2=string`. For a list of all the environment variables for the extension, see the [**Lambda environment variables** table](https://docs.logz.io/docs/shipping/Compute/Lambda-extensions#environment-variables) | |
#### Command example
```shell
Expand Down Expand Up @@ -115,13 +115,13 @@ aws lambda update-function-configuration \
2. In the page for the function, scroll down to the `Layers` section and choose `Add Layer`.
![Add layer](https://dytvr9ot2sszz.cloudfront.net/logz-docs/lambda_extensions/lambda-x_1-2.jpg)
3. Select the `Specify an ARN` option, then choose the ARN of the extension with the region code that matches your Lambda Function region from the [**ARNs** table]{@include: ../../_include/log-shipping/lambda-xtension-tablink.md}, and click the `Add` button.
3. Select the `Specify an ARN` option, then choose the ARN of the extension with the region code that matches your Lambda Function region from the [**ARNs** table](https://docs.logz.io/docs/shipping/aws/lambda-extensions/#arns), and click the `Add` button.
![Add ARN extension](https://dytvr9ot2sszz.cloudfront.net/logz-docs/lambda_extensions/lambda-x_1-3.jpg)
### Configure the extension parameters
Add environment variables to the function, according to the [**Environment variables** table]{@include: ../../_include/log-shipping/lambda-xtension-tablink-indox.html}.
Add environment variables to the function, according to the [**Environment variables** table](https://docs.logz.io/docs/shipping/Compute/Lambda-extensions#environment-variables).
#### Deleting the extension
Expand Down
8 changes: 6 additions & 2 deletions docs/shipping/App360/App360.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,15 @@ service:
traces:
receivers: [otlp]
processors: [tail_sampling, batch]
exporters: [logzio/traces, spanmetrics]
exporters: [logzio/traces]
traces/spm:
receivers: [otlp]
processors: [batch]
exporters: [spanmetrics]
metrics/spanmetrics:
receivers: [spanmetrics]
processors: [metricstransform/metrics-rename, metricstransform/labels-rename]
exporters: [prometheusremotewrite/spm]
exporters: [prometheusremotewrite/spm]
telemetry:
logs:
level: "debug"
Expand Down
235 changes: 117 additions & 118 deletions docs/shipping/Code/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,118 @@ if err != nil {
l.Stop() // Drains the log buffer
```

</TabItem>
<TabItem value="OpenTelemetry" label="OpenTelemetry">

This integration uses the OpenTelemetry logging exporter to send logs to Logz.io via the OpenTelemetry Protocol (OTLP) listener.

### Prerequisites

- Go 1.21 or newer

:::note
If you need an example aplication to test this integration, please refer to our [Go OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/go/logs).
:::

### Configure the instrumentation


1. Install OpenTelemetry dependencies:

```bash
go get go.opentelemetry.io/otel
go get go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp
go get go.opentelemetry.io/otel/exporters/stdout/stdoutlog
```

2. Create a new file named `otel.go` and add the following code to set up OpenTelemetry logging:


```go
package main

import (
"context"
"fmt"
"log"

"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
"go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
"go.opentelemetry.io/otel/log/global"
sdklog "go.opentelemetry.io/otel/sdk/log"
)

func newLoggerProvider() (*sdklog.LoggerProvider, error) {
// Create stdout log exporter
stdoutExporter, err := stdoutlog.New(stdoutlog.WithPrettyPrint())
if err != nil {
return nil, fmt.Errorf("failed to create stdout exporter: %w", err)
}

// Create OTLP HTTP log exporter for Logz.io
httpExporter, err := otlploghttp.New(context.Background(),
otlploghttp.WithEndpoint("otlp-listener.logz.io"),
otlploghttp.WithHeaders(map[string]string{
"Authorization": "Bearer <LOG-SHIPPING-TOKEN>",
"user-agent": "logzio-go-logs-otlp",
}),
otlploghttp.WithURLPath("/v1/logs"),
)
if err != nil {
return nil, fmt.Errorf("failed to create OTLP HTTP exporter: %w", err)
}

// Create a logger provider with both exporters
loggerProvider := sdklog.NewLoggerProvider(
sdklog.WithProcessor(sdklog.NewBatchProcessor(stdoutExporter)), // For stdout
sdklog.WithProcessor(sdklog.NewBatchProcessor(httpExporter)), // For HTTP export
)

return loggerProvider, nil
}

// setupOTelSDK bootstraps the OpenTelemetry logging pipeline.
func setupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error) {
// Set up logger provider.
loggerProvider, err := newLoggerProvider()
if err != nil {
return nil, err
}

// Set the global logger provider
global.SetLoggerProvider(loggerProvider)

// Return a shutdown function
shutdown = func(ctx context.Context) error {
err := loggerProvider.Shutdown(ctx)
if err != nil {
log.Printf("Error during logger provider shutdown: %v", err)
}
return err
}

return shutdown, nil
}

```


{@include: ../../_include/log-shipping/log-shipping-token.md}
Update the `listener.logz.io` part in `https://otlp-listener.logz.io/v1/logs` with the URL for [your hosting region](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region).


3. Run your application.

### Check Logz.io for your logs


Allow some time for data ingestion, then open [Open Search Dashboards](https://app.logz.io/#/dashboard/osd).

Encounter an issue? See our [log shipping troubleshooting](https://docs.logz.io/docs/user-guide/log-management/troubleshooting/log-shipping-troubleshooting/) guide.


</TabItem>
</Tabs>

## Metrics

Expand Down Expand Up @@ -379,119 +491,6 @@ Install the pre-built dashboard to enhance the observability of your metrics.

{@include: ../../_include/metric-shipping/generic-dashboard.html}

</TabItem>
<TabItem value="OpenTelemetry" label="OpenTelemetry">

This integration uses the OpenTelemetry logging exporter to send logs to Logz.io via the OpenTelemetry Protocol (OTLP) listener.

### Prerequisites

- Go 1.21 or newer

:::note
If you need an example aplication to test this integration, please refer to our [Go OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/go/logs).
:::

### Configure the instrumentation


1. Install OpenTelemetry dependencies:

```bash
go get go.opentelemetry.io/otel
go get go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp
go get go.opentelemetry.io/otel/exporters/stdout/stdoutlog
```

2. Create a new file named `otel.go` and add the following code to set up OpenTelemetry logging:


```go
package main

import (
"context"
"fmt"
"log"

"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
"go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
"go.opentelemetry.io/otel/log/global"
sdklog "go.opentelemetry.io/otel/sdk/log"
)

func newLoggerProvider() (*sdklog.LoggerProvider, error) {
// Create stdout log exporter
stdoutExporter, err := stdoutlog.New(stdoutlog.WithPrettyPrint())
if err != nil {
return nil, fmt.Errorf("failed to create stdout exporter: %w", err)
}

// Create OTLP HTTP log exporter for Logz.io
httpExporter, err := otlploghttp.New(context.Background(),
otlploghttp.WithEndpoint("otlp-listener.logz.io"),
otlploghttp.WithHeaders(map[string]string{
"Authorization": "Bearer <LOG-SHIPPING-TOKEN>",
"user-agent": "logzio-go-logs-otlp",
}),
otlploghttp.WithURLPath("/v1/logs"),
)
if err != nil {
return nil, fmt.Errorf("failed to create OTLP HTTP exporter: %w", err)
}

// Create a logger provider with both exporters
loggerProvider := sdklog.NewLoggerProvider(
sdklog.WithProcessor(sdklog.NewBatchProcessor(stdoutExporter)), // For stdout
sdklog.WithProcessor(sdklog.NewBatchProcessor(httpExporter)), // For HTTP export
)

return loggerProvider, nil
}

// setupOTelSDK bootstraps the OpenTelemetry logging pipeline.
func setupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error) {
// Set up logger provider.
loggerProvider, err := newLoggerProvider()
if err != nil {
return nil, err
}

// Set the global logger provider
global.SetLoggerProvider(loggerProvider)

// Return a shutdown function
shutdown = func(ctx context.Context) error {
err := loggerProvider.Shutdown(ctx)
if err != nil {
log.Printf("Error during logger provider shutdown: %v", err)
}
return err
}

return shutdown, nil
}

```


{@include: ../../_include/log-shipping/log-shipping-token.md}
Update the `listener.logz.io` part in `https://otlp-listener.logz.io/v1/logs` with the URL for [your hosting region](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region).


3. Run your application.

### Check Logz.io for your logs


Allow some time for data ingestion, then open [Open Search Dashboards](https://app.logz.io/#/dashboard/osd).

Encounter an issue? See our [log shipping troubleshooting](https://docs.logz.io/docs/user-guide/log-management/troubleshooting/log-shipping-troubleshooting/) guide.


</TabItem>
</Tabs>


## Traces

Expand Down Expand Up @@ -672,16 +671,16 @@ This integration uses OpenTelemetry Collector Contrib, not the OpenTelemetry Col
This layer contains the OpenTelemetry collector that will capture data from your application.

```shell
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:logzio-opentelemetry-collector-<<ARCHITECHTURE>>:<<VERSION>>
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers <<LAYER-ARN>>
```
Replace `<<YOUR-LAMBDA_FUNCTION_NAME>>` with the name of your Lambda function running the Java application.
Replace `<<YOUR-AWS-REGION>>` with the code of your AWS regions, e.g. `us-east-1`.
Replace `<<YOUR-LAMBDA_FUNCTION_NAME>>` with the name of your Lambda function running the Go application.
Copy the appropriate `<<LAYER-ARN>>` for your Lambda architecture (amd64 or arm64) from the [latest release notes](https://github.com/logzio/opentelemetry-lambda/releases).
Replace `<<ARCHITECTURE>>` with the target architecture for your Lambda function, either `arm64` for ARM-based applications or `amd64` (also known as x86_64) for traditional 64-bit Intel/AMD applications.
Replace `<<REGION>>` with the code of your AWS regions. [See all available Logz.io hosting regions](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region/#available-regions).
Replace `<<VERSION>>` with the latest version of the layer. You can find the latest version number by visiting the [Logz.io OpenTelemetry Lambda Releases page.](https://github.com/logzio/opentelemetry-lambda/releases)
#### Create a configuration file for the OpenTelemetry collector
Expand Down
15 changes: 9 additions & 6 deletions docs/shipping/Code/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -1428,20 +1428,23 @@ This integration uses OpenTelemetry Collector Contrib, not the OpenTelemetry Col
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --timeout 60
```
Replace `<<YOUR-LAMBDA_FUNCTION_NAME>>` with the name of the Lambda function you want to update.
#### Add the OpenTelemetry collector layer to your Lambda function
This layer contains the OpenTelemetry collector that will capture data from your application.
```shell
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:logzio-opentelemetry-collector-<<ARCHITECHTURE>>:<<VERSION>>
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers <<LAYER-ARN>>
```
Replace `<<YOUR-LAMBDA_FUNCTION_NAME>>` with the name of your Lambda function running the Java application.
Replace `<<YOUR-AWS-REGION>>` with the code of your AWS regions, e.g. `us-east-1`.
Replace `<<ARCHITECTURE>>` with the target architecture for your Lambda function, either `arm64` for ARM-based applications or `amd64` (also known as x86_64) for traditional 64-bit Intel/AMD applications.
Replace `<<VERSION>>` with the latest version of the layer. You can find the latest version number by visiting the [Logz.io OpenTelemetry Lambda Releases page.](https://github.com/logzio/opentelemetry-lambda/releases)
Copy the appropriate `<<LAYER-ARN>>` for your Lambda architecture (amd64 or arm64) from the [latest release notes](https://github.com/logzio/opentelemetry-lambda/releases).
Replace `<<REGION>>` with the code of your AWS regions. [See all available Logz.io hosting regions](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region/#available-regions).
#### Create a configuration file for the OpenTelemetry collector
Expand Down Expand Up @@ -1497,12 +1500,12 @@ The OpenTelemetry Java Agent layer automatically instruments the Java applicatio
Find the latest ARN for the OpenTelemetry Java Agent layer on the [OpenTelemetry Lambda GitHub Releases page](https://github.com/open-telemetry/opentelemetry-lambda/releases) under `layer-java`.
```shell
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers <LAYER_ARN>
aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers <<LAYER-ARN>>
```
Replace `<<YOUR-LAMBDA_FUNCTION_NAME>>` with the name of your Lambda function running the Java application.
`<<LAYER_ARN>>` with the latest ARN from the GitHub releases page.
Replace `<<YOUR-AWS-REGION>>` with the code of your AWS regions, e.g. `us-east-1`.
Replace `<<REGION>>` with the code of your AWS regions, e.g. `us-east-1`.
#### Add environment variable
Expand Down
21 changes: 13 additions & 8 deletions docs/shipping/Code/nestjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,24 @@ logzio-k8s-telemetry logzio-helm/logzio-k8s-telemetry
{@include: ../../_include/tracing-shipping/replace-tracing-token.html}
`<<LOGZIO_ACCOUNT_REGION_CODE>>` - Your Logz.io account region code. [Available regions](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region/#available-regions).

#### Define the logzio-k8s-telemetry service dns
#### Define the service DNS

You'll need the following service DNS:

`http://<<CHART-NAME>>-otel-collector.<<NAMESPACE>>.svc.cluster.local:<<PORT>>/`.

Replace `<<CHART-NAME>>` with the relevant service you're using (`logzio-k8s-telemetry`, `logzio-monitoring`).
Replace `<<NAMESPACE>>` with your Helm chart's deployment namespace (e.g., default or monitoring).
Replace `<<PORT>>` with the [port for your agent's protocol](https://github.com/logzio/logzio-helm/blob/master/charts/logzio-telemetry/values.yaml#L249-L267) (Default is 4317).

If you're not sure what your cluster domain name is, you can run the following command to look it up:

In most cases, the service dns will be `logzio-k8s-telemetry.default.svc.cluster.local`, where `default` is the namespace where you deployed the helm chart and `svc.cluster.name` is your cluster domain name.

If you are not sure what your cluster domain name is, you can run the following command to look it up:

```shell
kubectl run -it --image=k8s.gcr.io/e2e-test-images/jessie-dnsutils:1.3 --restart=Never shell -- \
sh -c 'nslookup kubernetes.default | grep Name | sed "s/Name:\skubernetes.default//"'
sh -c 'nslookup kubernetes.<<NAMESPACE>> | grep Name | sed "s/Name:\skubernetes.<<NAMESPACE>>//"'
```

It will deploy a small pod that extracts your cluster domain name from your Kubernetes environment. You can remove this pod after it has returned the cluster domain name.

It will deploy a small pod that extracts your cluster domain name from your Kubernetes environment. You can remove this pod after it has returned the cluster domain name.

#### Download instrumentation packages

Expand Down
Loading

0 comments on commit 907b739

Please sign in to comment.