|
| 1 | +--- |
| 2 | +aliases: |
| 3 | +- /es/logs/log_collection/apigee |
| 4 | +- /es/integrations/apigee |
| 5 | +description: Recopila logs de proxy de Apigee para realizar un seguimiento de errores, |
| 6 | + tiempos de respuesta de solicitudes, duración, latencia, rendimiento del monitor |
| 7 | + y problemas de proxies agregados en un solo lugar. |
| 8 | +further_reading: |
| 9 | +- link: logs/ |
| 10 | + tag: Documentación |
| 11 | + text: Log Management |
| 12 | +integration_id: apigee |
| 13 | +kind: Guía |
| 14 | +name: apigee |
| 15 | +short_description: Recopilar logs de Apigee |
| 16 | +title: Apigee |
| 17 | +--- |
| 18 | + |
| 19 | +## Información general |
| 20 | + |
| 21 | +Recopila logs de proxy de Apigee para realizar un seguimiento de errores, tiempos de respuesta, duración, latencia, rendimiento del monitor y problemas de proxies. |
| 22 | + |
| 23 | +## Configuración |
| 24 | + |
| 25 | +### Recopilación de logs |
| 26 | + |
| 27 | +{{% site-region region="us,eu" %}} |
| 28 | +Existen dos métodos para recopilar logs de Apigee: |
| 29 | + |
| 30 | +1. Utiliza la [política JavaScript][1] de Apigee para enviar logs a Datadog. |
| 31 | +2. Si ya dispones de un servidor syslog, utiliza el tipo de [política MessageLogging][2] de Apigee para gestionar logs en una cuenta syslog. |
| 32 | + |
| 33 | +#### Parámetro Syslog |
| 34 | + |
| 35 | +Utiliza el tipo de política MessageLogging con el parámetro syslog en tu API para registrar mensajes personalizados en syslog. Sustituye `<site_intake_endpoint>` por {{< region-param key="web_integrations_endpoint" code="true" >}} y `<site_port>` por {{< region-param key="web_integrations_port" code="true" >}}, en el siguiente ejemplo: |
| 36 | + |
| 37 | +```json |
| 38 | +<MessageLogging name="LogToSyslog"> |
| 39 | + <DisplayName>datadog-logging</DisplayName> |
| 40 | + <Syslog> |
| 41 | + <Message><YOUR API KEY> test</Message> |
| 42 | + <Host><site_intake_endpoint></Host> |
| 43 | + <Port><site_port></Port> |
| 44 | + <Protocol>TCP</Protocol> |
| 45 | + </Syslog> |
| 46 | +</MessageLogging> |
| 47 | +``` |
| 48 | + |
| 49 | +[1]: https://docs.apigee.com/api-platform/reference/policies/javascript-policy |
| 50 | +[2]: https://docs.apigee.com/api-platform/reference/policies/message-logging-policy#samples |
| 51 | + |
| 52 | +{{% /site-region %}} |
| 53 | +#### Política JavaScript |
| 54 | + |
| 55 | +Envía logs de proxy de Apigee a Datadog utilizando la [política JavaScript][1] de Apigee. |
| 56 | + |
| 57 | +El JavaScript se ha configurado para registrar las variables de flujo esenciales como atributos de logs en Datadog. Los atributos se nombran de acuerdo con la [lista de atributos estándar][2]. |
| 58 | + |
| 59 | +1. Selecciona el proxy de Apigee desde el que quieres enviar logs a Datadog. |
| 60 | +2. En la página de información general del proxy seleccionada, haz clic en la pestaña **DEVELOP** (Ampliar), situada en la esquina superior derecha. |
| 61 | + |
| 62 | +{{< img src="static/images/logs/guide/apigee/apigee_develop.png" alt="Ampliar" style="width:75%;">}} |
| 63 | + |
| 64 | +3. En **Navigator** (Navegador), añade una nueva política JavaScript y edita el archivo JavaScript creado en el menú desplegable **Resources --> jsc** (Recursos --> jsc). |
| 65 | +4. Añade el siguiente fragmento de código JavaScript en él. Asegúrate de sustituir `<Datadog_API_KEY>` en la variable `dd_api_url` por tu [clave de API Datadog][3]. |
| 66 | + |
| 67 | +``` |
| 68 | +// Configura la URL de la API Datadog aquí.. |
| 69 | +var dd_api_url = "https://http-intake.logs.{{< region-param key="dd_site" code="true" >}}/api/v2/logs?dd-api-key=<DATADOG_API_KEY>&ddsource=apigee"; |
| 70 | +
|
| 71 | +// Depurar |
| 72 | +// print(dd_api_url); |
| 73 | +// print('Name of the flow: ' + context.flow); |
| 74 | +
|
| 75 | +// calcular tiempos de respuesta de cliente, destino y total |
| 76 | +var request_start_time = context.getVariable('client.received.start.timestamp'); |
| 77 | +var request_end_time = context.getVariable('client.received.end.timestamp'); |
| 78 | +var system_timestamp = context.getVariable('system.timestamp'); |
| 79 | +var target_start_time = context.getVariable('target.sent.start.timestamp'); |
| 80 | +var target_end_time = context.getVariable('target.received.end.timestamp'); |
| 81 | +var total_request_time = system_timestamp - request_start_time; |
| 82 | +var total_target_time = target_end_time - target_start_time; |
| 83 | +var total_client_time = total_request_time - total_target_time; |
| 84 | +
|
| 85 | +var timestamp = crypto.dateFormat('YYYY-MM-dd HH:mm:ss.SSS'); |
| 86 | +var organization = context.getVariable("organization.name"); |
| 87 | +var networkClientIP = context.getVariable("client.ip"); |
| 88 | +var httpPort = context.getVariable("client.port"); |
| 89 | +var environment = context.getVariable("environment.name"); |
| 90 | +var apiProduct = context.getVariable("apiproduct.name"); |
| 91 | +var apigeeProxyName = context.getVariable("apiproxy.name"); |
| 92 | +var apigeeProxyRevision = context.getVariable("apiproxy.revision"); |
| 93 | +var appName = context.getVariable("developer.app.name"); |
| 94 | +var httpMethod = context.getVariable("request.verb"); |
| 95 | +var httpUrl = '' + context.getVariable("client.scheme") + '://' + context.getVariable("request.header.host") + context.getVariable("request.uri"); |
| 96 | +var httpStatusCode = context.getVariable("message.status.code"); |
| 97 | +var statusResponse = context.getVariable("message.reason.phrase"); |
| 98 | +var clientLatency = total_client_time; |
| 99 | +var targetLatency = total_target_time; |
| 100 | +var totalLatency = total_request_time; |
| 101 | +var userAgent = context.getVariable('request.header.User-Agent'); |
| 102 | +var messageContent = context.getVariable('message.content'); |
| 103 | +
|
| 104 | +
|
| 105 | +// Atributos de logs de Datadog |
| 106 | +var logObject = { |
| 107 | + "timestamp": timestamp, |
| 108 | + "organization": organization, |
| 109 | + "network.client.ip": networkClientIP, |
| 110 | + "env": environment, |
| 111 | + "apiProduct": apiProduct, |
| 112 | + "apigee_proxy.name": apigeeProxyName, |
| 113 | + "apigee_proxy.revision": apigeeProxyRevision, |
| 114 | + "service": appName, |
| 115 | + "http.method": httpMethod, |
| 116 | + "http.url": httpUrl, |
| 117 | + "http.status_code": httpStatusCode, |
| 118 | + "http.port": httpPort, |
| 119 | + "status": statusResponse, |
| 120 | + "clientLatency": clientLatency, |
| 121 | + "targetLatency": targetLatency, |
| 122 | + "totalLatency": totalLatency, |
| 123 | + "http.client.start_time_ms": request_start_time, |
| 124 | + "http.client.end_time_ms": request_end_time, |
| 125 | + "http.useragent": userAgent, |
| 126 | + "message": messageContent, |
| 127 | +}; |
| 128 | +
|
| 129 | +
|
| 130 | +var headers = { |
| 131 | + 'Content-Type': 'application/json' |
| 132 | +}; |
| 133 | +
|
| 134 | +
|
| 135 | +// Depurar |
| 136 | +// print('LOGGING OBJECT' + JSON.stringify(logObject)); |
| 137 | +
|
| 138 | +var myLoggingRequest = new Request(dd_api_url, "POST", headers, JSON.stringify(logObject)); |
| 139 | +
|
| 140 | +// Enviar logs a Datadog |
| 141 | +httpClient.send(myLoggingRequest); |
| 142 | +``` |
| 143 | + |
| 144 | +**Nota**: Añade más variables de flujo en JavaScript a partir de la [referencia de la variable de flujo Apigee][4]. |
| 145 | + |
| 146 | +## Solucionar problemas |
| 147 | + |
| 148 | +¿Necesitas ayuda? Ponte en contacto con el [servicio de asistencia de Datadog][5]. |
| 149 | + |
| 150 | +## Leer más |
| 151 | + |
| 152 | +{{< partial name="whats-next/whats-next.html" >}} |
| 153 | + |
| 154 | +[1]: https://docs.apigee.com/api-platform/reference/policies/javascript-policy |
| 155 | +[2]: /es/logs/log_configuration/attributes_naming_convention/#standard-attributes |
| 156 | +[4]: https://docs.apigee.com/api-platform/reference/variables-reference |
| 157 | +[5]: /es/help/ |
| 158 | +[3]: https://app.datadoghq.com/organization-settings/api-keys |
0 commit comments