Cree índices para un logstore específico.
Sintaxis de la solicitud
aliyunlog log create_index --project_name=<value> --logstore_name=<value> --index_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>]
Parámetros de la solicitud
A continuación se describen los parámetros obligatorios y específicos del comando create_index.
|
Parámetro |
Tipo |
Obligatorio |
Ejemplo |
Descripción |
|
--project_name |
String |
Sí |
aliyun-test-project |
El nombre del proyecto. |
|
--logstore_name |
String |
Sí |
logstroe-a |
El nombre del logstore. |
|
--index_detail |
JSON Object |
Sí |
file://./indexdetail.json |
La ruta del archivo de configuración que se utiliza para configurar los índices. Para obtener más información, consulte Create indexes y GitHub. |
Para obtener información sobre los parámetros globales de la interfaz de línea de comandos (CLI) de Simple Log Service, consulte Global parameters.
Ejemplos
-
Cree un archivo llamado indexdetail.json. A continuación se muestra el contenido del archivo indexdetail.json:
{ "keys": { "key1": { "caseSensitive": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text", "doc_value": true }, "key2": { "caseSensitive": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text", "doc_value": true }, "key3": { "caseSensitive": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text", "doc_value": true }, "key4": { "caseSensitive": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text", "doc_value": true } }, "storage": "pg", "ttl": 2, "index_mode": "v2", "line": { "caseSensitive": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ] } } -
Use la cuenta predeterminada para crear índices en un logstore llamado logstore-a. Ejecute el siguiente comando:
aliyunlog log create_index --project_name="aliyun-test-project" --logstore_name="logstore-a" --index_detail="file://./indexdetail.json" -
Consulte la configuración de los índices. Ejecute el siguiente comando:
aliyunlog log get_index_config --project_name="aliyun-test-project" --logstore_name="logstore-a" --format-output=jsonSe obtiene el siguiente resultado:
{ "index_mode": "v2", "keys": { "key1": { "caseSensitive": false, "doc_value": true, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text" }, "key2": { "caseSensitive": false, "doc_value": true, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text" }, "key3": { "caseSensitive": false, "doc_value": true, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text" }, "key4": { "caseSensitive": false, "doc_value": true, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ], "type": "text" } }, "lastModifyTime": 0, "line": { "caseSensitive": false, "chn": false, "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t" ] }, "storage": "pg", "ttl": 30 }
Códigos de error
Si se devuelve un mensaje de error, corrija el problema con base en los códigos de error de la API correspondiente. Para obtener más información, consulte Error codes.