ログストリーミング: New Relic OTLP

Fastly のリアルタイムログストリーミング機能によって、New Relic OTLP にログファイルを送信することができます。

注意

Fastly ではサードパーティのサービスに関する直接のサポートは行っておりません。詳細については、Fastly のご利用規約をご覧ください。

前提条件

Fastly サービスのログエンドポイントとして New Relic OTLP を追加する前に、以下が必要です。

ログエンドポイントとして New Relic OTLP を追加する

以下の手順で New Relic OTLP をログエンドポイントとして追加します。

  1. 配信サービス
  2. Compute サービス
  1. リモートログストリーミングの設定に関するガイドをご確認ください。
  2. New Relic OTLP エリアで、Create endpoint をクリックします。
  3. 以下の要領で Create a New Relic OTLP endpoint ページの各フィールドに入力します。
    • Name フィールドに分かりやすいエンドポイントの名前を入力します。
    • License key / Insert keyフィールドに、New Relic のライセンスキーまたは Insert API キーを入力します。
    • Region コントロールから、ログを配信するリージョンを選択します。
  4. (オプション) New Relic Infinite Tracing を使用している場合は、Advanced options をクリックし、Trace Observer URL フィールドに New Relic Trace Observer URL を入力します。
  5. Create をクリックして新規のログエンドポイントを作成します。
  6. Activate をクリックして設定への変更をデプロイします。
  7. 以下の手順に従って、VCL サービスを測定してください。

VCL サービスの測定

エンドポイントを設定した後で、カスタム VCL を追加してデータを収集し、エッジで Open Telemetry トレースを生成する必要があります。

  1. カスタム VCL ファイルの最上部に、以下の機能を配置します。

    1sub time_now_ns STRING {
    2 declare local var.time_now INTEGER;
    3 set var.time_now = std.atoi(time.start.usec);
    4 set var.time_now += std.atoi(time.elapsed.usec);
    5 set var.time_now *= 1000;
    6 return var.time_now;
    7}
    8sub random_8bit_identifier STRING {
    9 declare local var.id STRING;
    10 set var.id = randomstr(16, "0123456789abcdef");
    11 return var.id;
    12}
    13sub random_16bit_identifier STRING {
    14 declare local var.id STRING;
    15 set var.id = randomstr(32, "0123456789abcdef");
    16 return var.id;
    17}
    18sub otel_resource STRING {
    19 declare local var.str STRING;
    20 set var.str = {"{ "attributes": [ "}
    21 {"{ "key": "service.name", "value": { "stringValue": "Fastly www" } }, "}
    22 {"{ "key": "telemetry.sdk.language", "value": { "stringValue": "vcl" } }, "}
    23 {"{ "key": "telemetry.sdk.name", "value": { "stringValue": "opentelemetry" } }, "}
    24 {"{ "key": "telemetry.sdk.version", "value": { "stringValue": "1.0.1" } }, "}
    25 {"{ "key": "host.name", "value": { "stringValue": ""} server.identity {"" } }"}
    26 {"], "droppedAttributesCount": 0 }"};
    27 return var.str;
    28}
    29sub otel_attributes_general STRING {
    30 declare local var.data STRING;
    31 set var.data = ""
    32 {"{ "key": "http.method", "value": { "stringValue": ""} req.method {"" } },"}
    33 {"{ "key": "http.target", "value": { "stringValue": ""} req.url {"" } },"}
    34 {"{ "key": "http.host", "value": { "stringValue": ""} req.http.host {"" } },"}
    35 {"{ "key": "http.protocol", "value": { "stringValue": ""} req.protocol {"" } },"}
    36 {"{ "key": "http.client_ip", "value": { "stringValue": ""} client.ip {"" } },"}
    37 {"{ "key": "fastly.restarts", "value": { "stringValue": ""} req.restarts {"" } },"}
    38 {"{ "key": "fastly.visits_this_service", "value": { "stringValue": ""} fastly.ff.visits_this_service {"" } },"}
    39 {"{ "key": "fastly.server_role", "value": { "stringValue": ""} req.http.x-trace-server-role {"" } },"}
    40 {"{ "key": "fastly.server_ip", "value": { "stringValue": ""} server.ip {"" } },"}
    41 {"{ "key": "fastly.server_id", "value": { "stringValue": ""} server.identity {"" } },"}
    42 {"{ "key": "fastly.server_role", "value": { "stringValue": ""} req.http.x-trace-server-role {"" } },"}
    43 {"{ "key": "fastly.vcl_version", "value": { "stringValue": ""} req.vcl.version {"" } },"}
    44 {"{ "key": "fastly.pop", "value": { "stringValue": ""} server.datacenter {"" } },"}
    45 {"{ "key": "fastly.workspace.overflowed", "value": { "stringValue": ""} workspace.overflowed {"" } },"}
    46 {"{ "key": "fastly.workspace.bytes_total", "value": { "stringValue": ""} workspace.bytes_total {"" } },"}
    47 {"{ "key": "fastly.workspace.bytes_free", "value": { "stringValue": ""} workspace.bytes_free {"" } },"}
    48 ;
    49 return var.data;
    50}
    51sub telem_start_backend_fetch {
    52 set bereq.http.traceparent = "00-" req.http.x-trace-id + "-" + req.http.x-trace-vcl-span-id "-01";
    53 # Avoid leaking internal headers to backends
    54 unset bereq.http.x-trace-id;
    55 unset bereq.http.x-trace-parent-span-id;
    56 unset bereq.http.x-trace-server-role;
    57 # Leapfrog cloud service infra that creates 'ghost spans'
    58 set bereq.http.x-traceparent = bereq.http.traceparent;
    59}
  2. 次の VCL を vcl_recv サブルーチンの先頭に追加すると、Fastly POP 内のリクエストの有効期間全体のスパンが記録されます。

    1if (req.restarts == 0) {
    2 set req.http.x-trace-vcl-span-id = random_8bit_identifier();
    3 if (req.http.traceparent ~ "^\d+-(\w+)-(\w+)-\d+$") {
    4 set req.http.x-trace-id = re.group.1;
    5 set req.http.x-trace-parent-span-id = re.group.2;
    6 } else {
    7 set req.http.x-trace-id = random_16bit_identifier();
    8 }
    9 set req.http.x-trace-server-role = if (fastly.ff.visits_this_service == 0, "edge", "shield");
    10}
  3. 次の VCL を vcl_log サブルーチンの末尾に追加し、otel_collector_http をエンドポイントの名前で置き換えます。

    1declare local var.otel_resource STRING;
    2declare local var.otel_attribs STRING;
    3declare local var.time_start_ns STRING;
    4declare local var.time_now_ns STRING;
    5set var.time_start_ns = time.start.usec "000";
    6set var.time_now_ns = time_now_ns();
    7set var.otel_resource = otel_resource();
    8set var.otel_attribs = otel_attributes_general();
    9log "syslog " req.service_id " otel_collector_http :: "
    10 {"{ "resourceSpans": [ { "}
    11 {""resource": "} var.otel_resource {", "}
    12 {""instrumentationLibrarySpans": [ { "spans": [ { "}
    13 {""traceId": ""} req.http.x-trace-id {"", "}
    14 {""spanId": ""} req.http.x-trace-vcl-span-id {"", "}
    15 if(req.http.x-trace-parent-span-id,
    16 {""parentSpanId": ""} req.http.x-trace-parent-span-id {"", "},
    17 "")
    18 {""name": "Fastly request processing", "}
    19 {""kind": 1, "}
    20 {""startTimeUnixNano": "} var.time_start_ns {", "}
    21 {""endTimeUnixNano": "} var.time_now_ns {", "}
    22 {""attributes": [ "}
    23 var.otel_attribs
    24 {"{ "key": "http.user_agent", "value": { "stringValue": ""} req.http.User-Agent {"" } }, "}
    25 {"{ "key": "http.status_code", "value": { "stringValue": ""} resp.status {"" } }"}
    26 {"], "}
    27 {""status": { "code":"} if (fastly_info.state ~ "ERROR", "2", "0") {" }, "}
    28 {""links": [], "}
    29 {""droppedLinksCount": 0"}
    30 {"} ] } ]"}
    31 {"} ] }"}
    32;
  4. telem_start_backend_fetchコールを追加し、vcl_missvcl_pass サブルーチンに配置すると、Fastly スパンの子としてバックエンドシステムで発生するスパンが表示されます。

  5. サービスを有効にします。


翻訳についての注意事項
このガイドは役に立ちましたか?

このフォームを使用して機密性の高い情報を送信しないでください。サポートが必要な場合は、サポートチームまでご連絡ください。このフォームは reCAPTCHA によって保護されており、Google のプライバシーポリシー利用規約が適用されます。