全部产品
Search
文档中心

Simple Log Service:create_logtail_config

更新时间:Jul 06, 2025

Membuat konfigurasi Logtail.

Sintaks permintaan

aliyunlog log create_logtail_config --project_name=<value> --config_detail=<value> [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>]

Parameter permintaan

Tabel berikut menjelaskan parameter yang diperlukan dan spesifik dari perintah create_logtail_config.

Parameter

Tipe

Diperlukan

Contoh

Deskripsi

--project_name

String

Ya

test

Nama proyek.

--config_detail

String

Ya

file://./logtailconfig.json

Path file konfigurasi Logtail. Untuk informasi lebih lanjut, lihat Konfigurasi Logtail.

Untuk informasi tentang parameter global dari antarmuka baris perintah (CLI) Layanan Log, lihat Parameter Global.

Contoh

  1. Buat file logtailconfig.json di mana konfigurasi Logtail diberi nama config_name2. Contoh berikut menunjukkan isi file createshipper.json:

    {
      "config_name": "config_name2",
      "logstore_name": "logstore-a",
      "file_pattern": "file_pattern",
      "time_format": "time_format",
      "log_path": "/log_path",
      "endpoint": "endpoint",
      "log_parse_regex": "xxx ([\\w\\-]+\\s[\\d\\:]+)\\s+(.*)",
      "log_begin_regex": "xxx.*",
      "reg_keys": [
        "time",
        "value"
      ],
      "topic_format": "none",
      "filter_keys": [
        "time",
        "value"
      ],
      "filter_keys_reg": [
        "time",
        "value"
      ],
      "logSample": "xxx 2017-11-11 11:11:11 hello alicloud."
    }
  2. Gunakan akun default untuk membuat konfigurasi Logtail dengan nama config_name2.

    aliyunlog log create_logtail_config --project_name="aliyun-test-project" --config_detail="file://./logtailconfig.json"
  3. Kueri konfigurasi Logtail yang telah dibuat. Jalankan perintah berikut:

    aliyunlog log get_logtail_config --project_name="aliyun-test-project" --config_name="config_name2"

    Keluaran berikut dikembalikan:

    { "configName": "config_name2",
      "createTime": 1622118681,
      "inputDetail": {
        "adjustTimezone": false,
        "delayAlarmBytes": 0,
        "delaySkipBytes": 0,
        "discardNonUtf8": false,
        "discardUnmatch": true,
        "dockerFile": false,
        "enableRawLog": false,
        "enableTag": false,
        "fileEncoding": "utf8",
        "filePattern": "file_pattern",
        "filterKey": [
          "time",
          "value"
        ],
        "filterRegex": [
          "time",
          "value"
        ],
        "key": [
          "time",
          "value"
        ],
        "localStorage": true,
        "logBeginRegex": "xxx.*",
        "logPath": "/log_path",
        "logTimezone": "",
        "logType": "common_reg_log",
        "maxDepth": 1000,
        "maxSendRate": -1,
        "mergeType": "topic",
        "preserve": true,
        "preserveDepth": 0,
        "priority": 0,
        "regex": "xxx ([\\w\\-]+\\s[\\d\\:]+)\\s+(.*)",
        "sendRateExpire": 0,
        "sensitive_keys": [],
        "tailExisted": false,
        "timeFormat": "time_format",
        "topicFormat": "none"
      },
      "inputType": "file",
      "lastModifyTime": 1622118681,
      "logSample": "xxx 2017-11-11 11:11:11 hello alicloud.",
      "outputDetail": {
        "endpoint": "cn-hangzhou-b-intranet.log.aliyuncs.com",
        "logstoreName": "logstore-a",
        "region": "cn-hangzhou-b"
      },
      "outputType": "LogService"
    }

Kode kesalahan

Jika pesan kesalahan dikembalikan, perbaiki kesalahan berdasarkan kode kesalahan operasi API terkait. Untuk informasi lebih lanjut, lihat Kode Kesalahan.

Referensi API

CreateConfig