|
| 1 | +--- |
| 2 | +id: generate-new-url-with-auth-header |
| 3 | +title: Generate a New URL for an HTTP Source with an Auth Header |
| 4 | +sidebar_label: Regenerate URL |
| 5 | +--- |
| 6 | + |
| 7 | +import useBaseUrl from '@docusaurus/useBaseUrl'; |
| 8 | + |
| 9 | +<head> |
| 10 | + <meta name="robots" content="noindex" /> |
| 11 | +</head> |
| 12 | + |
| 13 | +<p><a href={useBaseUrl('docs/beta')}><span className="beta">Beta</span></a></p> |
| 14 | + |
| 15 | +Sumo Logic offers secure token-based authentication for the HTTPS Logs and Metrics Source. This capability allows you to authenticate using a unique token in the request header, maintaining the existing HTTPS endpoint behavior while adding token validation per source. Obtain the token to use in an auth header when you configure an HTTP source or regenerate the URL. |
| 16 | + |
| 17 | +## Generate a new URL for an HTTP source |
| 18 | + |
| 19 | +You can generate a new URL for an HTTP Source at any time. Generating a new URL completely invalidates the old URL. |
| 20 | + |
| 21 | +To generate a new URL: |
| 22 | + |
| 23 | +1. [**New UI**](/docs/get-started/sumo-logic-ui). In the Sumo Logic main menu select **Data Management**, and then under **Data Collection** select **Collection**. You can also click the **Go To...** menu at the top of the screen and select **Collection**. <br/>[**Classic UI**](/docs/get-started/sumo-logic-ui-classic). In the main Sumo Logic menu, select **Manage Data > Collection > Collection**. |
| 24 | +1. On the **Manage Collection** page, click **Regenerate URL** next to the HTTP source.<br/><img src={useBaseUrl('img/send-data/regenerate-url.png')} alt="Regenerate URL link" style={{border: '1px solid gray'}} width="800" /> |
| 25 | +1. In the **HTTP Source Address** dialog box, select one of the following to regenerate the URL where the source data will be stored: |
| 26 | + * **Presigned URL**. Select to copy a presigned URL with embedded authentication.<br/><img src={useBaseUrl('img/send-data/generate-new-url-new.png')} alt="Generate New URL" style={{border: '1px solid gray'}} width="600"/> |
| 27 | + * **Auth Header**. Select to copy the URL, as well as a separate authorization header that contains an authentication token. This option provides greater security than a presigned URL because placing the authentication token in the authorization header of a request prevents the token from being exposed in the URL.<br/><img src={useBaseUrl('img/send-data/generate-new-url-and-token.png')} alt="Generate New URL and token" style={{border: '1px solid gray'}} width="600"/> |
| 28 | +1. Click **Generate**. |
| 29 | +1. When asked to confirm the generation, click **OK**. |
| 30 | +1. In the resulting dialog box, the newly-generated URL is displayed, as well as the authorization header if you selected **Auth Header**. Copy the URL (and header if applicable) and keep in a safe place. |
| 31 | +1. Use the copied URL (and header if appropriate) when you [upload data to your HTTP Logs and Metrics source](/docs/send-data/hosted-collectors/http-source/logs-metrics/#upload-data-to-the-httplogs-and-metrics-source). |
| 32 | + |
| 33 | +:::note |
| 34 | +If you see a 401 (failed to authenticate) error message right after generating a new URL, wait a few minutes, then try the new URL again. |
| 35 | +::: |
| 36 | + |
| 37 | +## Upload logs to an HTTP source |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +### Upload log data with a POST request |
| 42 | + |
| 43 | +When you [upload log with a POST request](/docs/send-data/hosted-collectors/http-source/logs-metrics/upload-logs/#upload-log-data-with-a-post-request), keep in mind the following. |
| 44 | + |
| 45 | +To upload log data with a POST request, include the complete data payload as the request body. Any query parameters will be ignored. |
| 46 | + |
| 47 | +:::important |
| 48 | +We recommend that the POST data payload have a size, before compression, of 100KB to 1MB. See [data payload considerations](/docs/send-data/hosted-collectors/http-source/logs-metrics/#data-payload-considerations) for details. |
| 49 | +::: |
| 50 | + |
| 51 | +* Data payload: |
| 52 | + * Data line 1 |
| 53 | + * Data line 2 |
| 54 | + * Data line 3 |
| 55 | +* Method: POST |
| 56 | +* URL: <br/>Enter the URL obtained when you configure the HTTP Logs and Metrics Source or when you regenerate the URL. Enter either a presigned URL or a URL to be used with an auth header: |
| 57 | + * Presigned URL: `https://[SumoEndpoint]/receiver/v1/http/[UniqueHTTPCollectorCode]` <br/>where |
| 58 | + * [SumoEndpoint] is your Sumo collection endpoint |
| 59 | + * [UniqueHTTPCollectorCode] is the string that follows the last forward slash (`/`) in the upload URL for the HTTP source |
| 60 | + * URL used with auth header: `https://[SumoEndpoint]/receiver/v1/http` <br/>where [SumoEndpoint] is your Sumo collection endpoint |
| 61 | +* Body |
| 62 | + * Data line 1 |
| 63 | + * Data line 2 |
| 64 | + * Data line 3 |
| 65 | + |
| 66 | +### Supported HTTP Headers |
| 67 | + |
| 68 | +The following parameters can be specified via headers when sending data to an HTTP Source. The settings will apply to all messages in the request. For Source Name, Host, and Category, the header value will override any default value already specified for the source and/or collector. |
| 69 | + |
| 70 | +You can configure your Source to process HTTP Headers into metadata fields. See [HTTP Source fields](/docs/manage/fields) for details. |
| 71 | + |
| 72 | +:::note |
| 73 | +Overridden metadata field values are not returned with [Search Autocomplete](/docs/search/get-started-with-search/search-basics/search-autocomplete). |
| 74 | +::: |
| 75 | + |
| 76 | +| Setting | Header Name | Header Value | |
| 77 | +|:--|:--|:--| |
| 78 | +| Compressed data | `Content-Encoding` | Values can be `zstd`, `gzip`, or `deflate`.<br/>Required if you are uploading compressed data. | |
| 79 | +| Custom Source Name | `X-Sumo-Name` | Desired source name.<br/>Useful if you want to override the source name configured for the source. | |
| 80 | +| Custom Source Host | `X-Sumo-Host` | Desired host name.<br/>Useful if you want to override the source host configured for the source. | |
| 81 | +| Custom Source Category | `X-Sumo-Category` | Desired source category.<br/>Useful if you want to override the source category configured for the source. | |
| 82 | +| Fields as custom metadata | `X-Sumo-Fields` | [Fields](/docs/manage/fields) need to be in a comma separated list of key-value pairs. | |
| 83 | +| Token authentication | `x-sumo-token` | Token to be used for authentication in an authorization header. Obtain the token when you select **Auth Header** when you [configure the HTTP Logs and Metrics Source](/docs/send-data/hosted-collectors/http-source/logs-metrics/#configure-an-httplogs-and-metrics-source), or when you [regenerate the URL](/docs/send-data/hosted-collectors/http-source/generate-new-url/). | |
| 84 | + |
| 85 | +### Command line examples |
| 86 | + |
| 87 | +:::note |
| 88 | +Data is ingested according to the configured [processing rules](/docs/send-data/collection/processing-rules). Messages blocked by filters will not be ingested. |
| 89 | +::: |
| 90 | + |
| 91 | +#### cURL |
| 92 | + |
| 93 | +When using cURL to POST data from a file: |
| 94 | + |
| 95 | +* Make sure to use the -T parameter to specify the file path, not -d. The -d parameter causes new lines to be removed from the content, which will interfere with message boundary detection. |
| 96 | +* Make sure that each line in the file follows the format specified by the Content-Type header for the HTTP request. |
| 97 | +* Enter the URL (and auth header if applicable) obtained when you [configured the HTTP Logs and Metrics Source](/docs/send-data/hosted-collectors/http-source/logs-metrics/#configure-an-httplogs-and-metrics-source) or when you [regenerate the URL](/docs/send-data/hosted-collectors/http-source/generate-new-url/). If you use an auth header, enter it in this format: <br/>`-H "x-sumo-token: [TokenString]"` |
| 98 | + |
| 99 | +**POST upload** |
| 100 | + |
| 101 | +Presigned URL: |
| 102 | +```bash |
| 103 | +curl -v -X POST -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode] |
| 104 | +``` |
| 105 | +URL with auth header: |
| 106 | +```bash |
| 107 | +curl -v -X POST -H "x-sumo-token: [TokenString]" -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http |
| 108 | +``` |
| 109 | + |
| 110 | +**POST upload (gzip compressed data)** |
| 111 | + |
| 112 | +Presigned URL: |
| 113 | +```bash |
| 114 | +curl -v -X POST -H 'Content-Encoding:gzip' -T [local_file_name.gz] https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode] |
| 115 | +``` |
| 116 | + |
| 117 | +URL with auth header: |
| 118 | +```bash |
| 119 | +curl -v -X POST -H 'Content-Encoding:gzip' -H "x-sumo-token: [TokenString]" -T [local_file_name.gz] https://collectors.sumologic.com/receiver/v1/http |
| 120 | +``` |
| 121 | + |
| 122 | +**POST upload with custom Source Category** |
| 123 | + |
| 124 | +Presigned URL: |
| 125 | +```bash |
| 126 | +curl -v -X POST -H 'X-Sumo-Category:myNewCategory' -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode] |
| 127 | +``` |
| 128 | + |
| 129 | +URL with auth header: |
| 130 | +```bash |
| 131 | +curl -v -X POST -H 'X-Sumo-Category:myNewCategory' -H "x-sumo-token: [TokenString]" -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http |
| 132 | +``` |
| 133 | + |
| 134 | +**POST upload with custom Fields** |
| 135 | + |
| 136 | +Presigned URL: |
| 137 | +```bash |
| 138 | +curl -v -X POST -H 'X-Sumo-Fields:environment=dev,cluster=k8s' -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode] |
| 139 | +``` |
| 140 | +URL with auth header: |
| 141 | +```bash |
| 142 | +curl -v -X POST -H 'X-Sumo-Fields:environment=dev,cluster=k8s' -H "x-sumo-token: [TokenString]" -T [local_file_name] https://collectors.sumologic.com/receiver/v1/http |
| 143 | +``` |
| 144 | + |
| 145 | +#### PowerShell |
| 146 | + |
| 147 | +**POST upload** |
| 148 | + |
| 149 | +In the following examples when a URL is used with an auth header, `$headers` is defined as follows: |
| 150 | + |
| 151 | +```bash |
| 152 | +$headers = @{ |
| 153 | + Authorization="x-sumo-token: [TokenString]" |
| 154 | + Content='application/json' |
| 155 | +} |
| 156 | +``` |
| 157 | + |
| 158 | +Presigned URL: |
| 159 | +```bash |
| 160 | +Invoke-WebRequest -Method POST -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode]' |
| 161 | +``` |
| 162 | + |
| 163 | +URL with auth header: |
| 164 | +```bash |
| 165 | +Invoke-WebRequest -Method POST -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http' -Headers $headers |
| 166 | +``` |
| 167 | + |
| 168 | +**POST upload (gzip compressed data)** |
| 169 | + |
| 170 | +Presigned URL: |
| 171 | +```bash |
| 172 | +Invoke-WebRequest -Method POST -Headers @{'Content-Encoding' = 'gzip'} -InFile [local_file_name.gz] 'https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode]' |
| 173 | +``` |
| 174 | + |
| 175 | +URL with auth header: |
| 176 | +```bash |
| 177 | +Invoke-WebRequest -Method POST -Headers @{'Content-Encoding' = 'gzip'} -InFile [local_file_name.gz] 'https://collectors.sumologic.com/receiver/v1/http' -Headers $headers |
| 178 | +``` |
| 179 | + |
| 180 | +**POST upload with custom Source Category** |
| 181 | + |
| 182 | +Presigned URL: |
| 183 | +```bash |
| 184 | +Invoke-WebRequest -Method POST -Headers @{'X-Sumo-Category' = 'myCustomCategory'} -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode]' |
| 185 | +``` |
| 186 | + |
| 187 | +URL with auth header: |
| 188 | +```bash |
| 189 | +Invoke-WebRequest -Method POST -Headers @{'X-Sumo-Category' = 'myCustomCategory'} -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http' -Headers $headers |
| 190 | +``` |
| 191 | + |
| 192 | +**POST upload with custom Field** |
| 193 | + |
| 194 | +Presigned URL: |
| 195 | +```bash |
| 196 | +Invoke-WebRequest -Method POST -Headers @{'X-Sumo-Fields' = 'environment=dev'} -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http/[UniqueHTTPCollectorCode]' |
| 197 | +``` |
| 198 | + |
| 199 | +URL with auth header: |
| 200 | +```bash |
| 201 | +Invoke-WebRequest -Method POST -Headers @{'X-Sumo-Fields' = 'environment=dev'} -InFile [local_file_name] 'https://collectors.sumologic.com/receiver/v1/http' -Headers $headers |
| 202 | +``` |
0 commit comments