Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _source/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h1 class="post-title">
</div> <!-- /.body-container -->
</div> <!-- /div.big-container -->
{% include templates/footer.html %}

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="{{ 'js/tab_toc.js' | relative_url }}"></script>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cycode: SAST violation: 'Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')'.

Detected a template variable used in a script tag. Although template variables are HTML escaped, HTML escaping does not always prevent cross-site scripting (XSS) attacks when used directly in JavaScript. If you need this data on the rendered page, consider placing it in the HTML portion (outside of a script tag). Alternatively, use a JavaScript-specific encoder, such as the one available in OWASP ESAPI. For Django, you may also consider using the 'json_script' template tag and retrieving the data in your script by using the element ID (e.g., document.getElementById).

Severity: Critical

Would you like to exclude this SAST violation from your status checks?
Tell us what to do with one of the following hashtags:

Tag Short Description
#cycode_sast_ignore_everywhere Applies to this SAST violation for all repos in your organization
#cycode_sast_ignore_here Applies to this request only
#cycode_sast_false_positive Applies to this SAST violation for all repos in your organization


</body>

</html>
8 changes: 8 additions & 0 deletions _source/css/logz-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ ol .branching-tabs {
padding-top: 12px;
}

.toc-container {
position: sticky;
top: 80px;
max-height: calc(100vh - 80px);
overflow-y: auto;
margin-right: 20px;
}

/* ===== LOG SHIPPING PAGES ===== */

#on-this-page-toc {
Expand Down
46 changes: 46 additions & 0 deletions _source/js/tab_toc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
document.addEventListener("DOMContentLoaded", function() {
function generateTOC(tabContent, tocContainer) {
const headings = tabContent.find('h1, h2, h3, h4, h5, h6');
let tocList = '';

headings.each((index, heading) => {
const anchorId = `${tabContent.attr('id')}-heading-${index}`;
$(heading).attr('id', anchorId);

tocList += `<li><a href="#${anchorId}">${heading.innerText}</a></li>`;
});

tocContainer.html(`<ul>${tocList}</ul>`);
}

function switchTab(e) {
e.preventDefault();

const targetTabId = $(this).attr('href').slice(1);
const allTabs = $('.tab-content');
const allBranchingTabs = $('.branching-tabs');

allTabs.hide();
allBranchingTabs.removeClass('active');

$(`#${targetTabId}`).show();
$(this).addClass('active');
}

$(document).ready(function() {
const tabContents = $('.tab-content');
tabContents.each(function() {
const tocContainer = $(this).find('.toc-container');
generateTOC($(this), tocContainer);
});

const branchingTabs = $('.branching-tabs');
branchingTabs.on('click', switchTab);

// Show the first tab as the default active tab
const firstTabId = branchingTabs.first().attr('href').slice(1);
$(`#${firstTabId}`).show();
branchingTabs.first().addClass('active');
});
});

198 changes: 13 additions & 185 deletions _source/logzio_collections/_log-sources/apprunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,215 +14,43 @@ shipping-tags:
- aws
order: 110
---

<!-- tabContainer:start -->
<div class="branching-container">

* [Overview](#overview)
* [Manual Lambda configuration](#manual-lambda-configuration)
* [Automated CloudFormation deployment](#automated-cloudformation-deployment)
* [Manual Lambda configuration](#manual)
* [Automated CloudFormation deployment](#automated)
{:.branching-tabs}

<!-- tab:start -->
<div id="overview">
<div id="manual" class="tab-content" markdown="1">

AWS App Runner is a fully managed service for deployment of containerized web applications and APIs. This integration allows you to send logs from your AppRunner instances to your Logz.io account.
<div class="toc-container"></div>

</div>
<!-- tab:end -->

<!-- tab:start -->
<div id="manual-lambda-configuration">
<h2>Manual configuration with a Lambda function</h2>

#### Manual configuration with a Lambda function

{% include log-shipping/note-lambda-test.md %}

<div class="tasklist">
test

##### Create a new Lambda function

This Lambda function will collect AppRunner logs and sends them to Logz.io in bulk over HTTPS.

Open the AWS Lambda Console, and click **Create function**.
Choose **Author from scratch**, and use this information:

* **Name**: We suggest adding the log type to the name, but you can name this function whatever you want.
* **Runtime**: Choose **Python 3.7**
* **Role**: Click **Create new role from template(s)**. Then, from the **Policy Templates** list, select **Basic Edge Lambda permissions**.

Click **Create Function** (bottom right corner of the page). After a few moments, you'll see configuration options for your Lambda function.

You'll need this page later on, so keep it open.

##### Zip the source files

Clone the AppRunner Logs Shipper - Lambda project from GitHub to your computer,
and zip the Python files in the `src/` folder.

```shell
git clone https://github.com/logzio/logzio_aws_serverless.git \
&& cd logzio_aws_serverless/python3/apprunner/ \
&& mkdir -p dist/python3/shipper; cp -r ../shipper/shipper.py dist/python3/shipper \
&& cp src/lambda_function.py dist \
&& cd dist/ \
&& zip logzio-apprunner lambda_function.py python3/shipper/*
```

You'll upload `logzio-apprunner.zip` in the next step.

##### Upload the zip file and set environment variables

In the _Function_ code section of Lambda, find the **Code entry type** list. Choose **Upload a .ZIP file** from this list.

Click **Upload**, and choose the zip file you created earlier (`logzio-apprunner.zip`).

In the _Environment variables_ section, set your Logz.io account token, URL, and log type, and any other variables that you need to use.

###### Environment variables

| Parameter | Description | Required/Default |
|---|---|---|
| TOKEN | Your Logz.io account token. {% include log-shipping/log-shipping-token.html %} | Required |
| REGION | {% include log-shipping/log-region.html %}
| URL (Deprecated) | Use REGION instead. | -- |
| TYPE | The log type you'll use with this Lambda. This can be a [built-in log type]({{site.baseurl}}/user-guide/log-shipping/built-in-log-types.html), or a custom log type. You should create a new Lambda for each log type you use. | `logzio_apprunner_lambda` |
| FORMAT | `json` or `text`. If `json`, the Lambda function will attempt to parse the message field as JSON and populate the event data with the parsed fields. | `text` |
| COMPRESS | Set to `true` to compress logs before sending them. Set to `false` to send uncompressed logs. | `false` |
| ENRICH | Enrich AppRunner events with custom properties, formatted as `key1=value1;key2=value2`. | -- |




##### Configure the function's basic settings

In Basic settings, we recommend starting with these settings:

* **Memory**: 512 MB
* **Timeout**: 1 min 0 sec

<!-- info-box-start:info -->
These default settings are just a starting point.
Check your Lambda usage regularly, and adjust these values if you need to.
{:.info-box.note}
<!-- info-box-end -->


{% include log-shipping/apprunner-defaults.md %}


##### Set the AppRunner Logs event trigger

1. Find the **Add triggers** list (left side of the Designer panel). Choose **CloudWatch Logs** from this list.

2. Below the Designer, you'll see the Configure triggers panel. In the **Log groups**, search for the AppRunner option and select it as the trigger for the Lambda function.

3. Type a **Filter name** (required) and **Filter pattern** (optional).

4. Click **Add**, then **Save** at the top of the page.

##### Check Logz.io for your logs

Give your logs some time to get from your system to ours, and then open [Open Search Dashboards](https://app.logz.io/#/dashboard/osd).

If you still don't see your logs, see [log shipping troubleshooting]({{site.baseurl}}/user-guide/log-shipping/log-shipping-troubleshooting.html).

</div>

test
</div>
<!-- tab:end -->

<!-- tab:start -->
<div id="automated-cloudformation-deployment">

#### Automated CloudFormation deployment
<div id="automated" class="tab-content" markdown="1">

{% include log-shipping/note-lambda-test.md %}
<div class="toc-container"></div>

**Before you begin, you'll need**:
AWS CLI,
an S3 bucket to store the CloudFormation package
#### Automated CloudFormation deployment

<div class="tasklist">
test

##### Zip the source files

Clone the AppRunner Logs Shipper - Lambda project from GitHub to your computer,
and zip the Python files in the `src/` folder.

```shell
git clone https://github.com/logzio/logzio_aws_serverless.git \
&& cd logzio_aws_serverless/python3/apprunner/ \
&& mkdir -p dist/python3/shipper; cp -r ../shipper/shipper.py dist/python3/shipper \
&& cp src/lambda_function.py dist \
&& cd dist/ \
&& zip logzio-apprunner lambda_function.py python3/shipper/*
```

##### Create the CloudFormation package and upload to S3

Create the CloudFormation package using the AWS CLI.
Replace `<<YOUR-S3-BUCKET>>` with the S3 bucket name where you'll be uploading this package.

```shell
cd ../ \
&& aws cloudformation package \
--template sam-template.yaml \
--output-template-file cloudformation-template.output.yaml \
--s3-bucket <<YOUR-S3-BUCKET>>
```

##### Deploy the CloudFormation package

Deploy the CloudFormation package using AWS CLI.

For a complete list of options, see the configuration parameters below the code block. 👇

```shell
aws cloudformation deploy \
--template-file $(pwd)/cloudformation-template.output.yaml \
--stack-name logzio-apprunner-logs-lambda-stack \
--parameter-overrides \
LogzioTOKEN='<<LOG-SHIPPING-TOKEN>>' \
--capabilities "CAPABILITY_IAM"
```


###### Parameters

| Parameter | Description | Required/Default |
|---|---|---|
| LogzioTOKEN | Your Logz.io account token. {% include log-shipping/log-shipping-token.html %} | Required |
| LogzioREGION | {% include log-shipping/log-region.html %}
| LogzioURL (Deprecated) | Use LogzioREGION instead. Protocol, listener host, and port (for example, `https://<<LISTENER-HOST>>:8071`). The [token](https://app.logz.io/#/dashboard/settings/general) of the account you want to ship to. | -- |
| LogzioTYPE | The log type you'll use with this Lambda. This can be a [built-in log type](https://docs.logz.io/user-guide/log-shipping/built-in-log-types.html), or a custom log type. You should create a new Lambda for each log type you use. | `logzio_apprunner_logs` |
| LogzioFORMAT | `json` or `text`. If `json`, the Lambda function will attempt to parse the message field as JSON and populate the event data with the parsed fields. | `text` |
| LogzioCOMPRESS | Set to `true` to compress logs before sending them. Set to `false` to send uncompressed logs. | `false` |
| LogzioENRICH | Enrich AppRunner events with custom properties, formatted as `key1=value1;key2=value2`. | -- |



{% include log-shipping/apprunner-defaults.md %}


##### Set the AppRunner Logs event trigger

1. Find the **Add triggers** list (left side of the Designer panel). Choose **CloudWatch Logs** from this list.

2. Below the Designer, you'll see the Configure triggers panel. In the **Log groups**, search for the AppRunner option and select it as the trigger for the Lambda function.

3. Type a **Filter name** (required) and **Filter pattern** (optional).

4. Click **Add**, then **Save** at the top of the page.

##### Check Logz.io for your logs

Give your logs some time to get from your system to ours, and then open [Open Search Dashboards](https://app.logz.io/#/dashboard/osd).

If you still don't see your logs, see [log shipping troubleshooting]({{site.baseurl}}/user-guide/log-shipping/log-shipping-troubleshooting.html).

test
</div>
<!-- tab:end -->


</div>
<!-- tabContainer:end -->