DataDog / datadog-api-client-typescript

Typescript client for the Datadog API
https://www.npmjs.com/package/@datadog/datadog-api-client
Apache License 2.0
81 stars 15 forks source link

How do you specify an eu server when using the v2.LogsAPI methods? #802

Closed theogravity closed 2 years ago

theogravity commented 2 years ago

https://datadoghq.dev/datadog-api-client-typescript/classes/v2.LogsApi.html

Where would you specify the eu server for log ingestion?

therve commented 2 years ago

Hi,

https://github.com/DataDog/datadog-api-client-typescript#changing-server should have the response. Thanks.

theogravity commented 2 years ago

@therve

I have a user reporting that the site specification isn't working in:

https://github.com/theogravity/pino-datadog-transport/issues/5

My integration code looks like this:

import build from 'pino-abstract-transport'
import { client, v2 } from '@datadog/datadog-api-client'
import { DDTransportOptions, processLogBuilder } from './process-logs'

module.exports = function (options: DDTransportOptions) {
  const configuration = client.createConfiguration(options.ddClientConf)
  client.setServerVariables(configuration, options?.ddServerConf || {})
  const apiInstance = new v2.LogsApi(configuration)

  return build(processLogBuilder(options, apiInstance))
}

Do I need to do anything specifically with the client, or is the config global?

The user is passing the ddServerConf var via:

ddServerConf: { site: 'datadoghq.eu' }

I eventually send the logs via:

 const params: LogsApiSubmitLogRequest = {
        body: logsToSend,
        contentEncoding: 'gzip',
      }

 const result = await apiInstance.submitLog(params)
therve commented 2 years ago

That looks correct. Your user should check if the 403 comes from the EU server.

theogravity commented 2 years ago

User now reports it's working fine, must have been some transient issue. Thanks.