From e3e6e4d9e99b8efadc440a5c6f73fa9df8b8c0e2 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 16 Dec 2024 16:25:36 +0100 Subject: [PATCH 1/3] Add initial support for structured settings references (yaml) --- docs/source/elastic/reference/index.md | 7 +- .../kibana-alerting-action-settings.yml | 749 ++++++++++++++++++ docs/source/markup/substitutions.md | 11 +- .../ProcessorDiagnosticExtensions.cs | 43 +- src/Elastic.Markdown/IO/MarkdownFile.cs | 2 +- .../Myst/Directives/AdmonitionBlock.cs | 12 +- .../Myst/Directives/AppliesBlock.cs | 9 +- .../Myst/Directives/CodeBlock.cs | 8 +- .../Myst/Directives/DirectiveBlock.cs | 26 +- .../Myst/Directives/DirectiveBlockParser.cs | 25 +- .../Myst/Directives/DirectiveHtmlRenderer.cs | 50 +- .../Myst/Directives/ImageBlock.cs | 13 +- .../Myst/Directives/IncludeBlock.cs | 8 +- .../Myst/Directives/MermaidBlock.cs | 4 +- .../Myst/Directives/SettingsBlock.cs | 61 ++ .../Myst/Directives/TabSetBlock.cs | 12 +- .../Myst/Directives/UnknownDirectiveBlock.cs | 8 +- .../Directives/UnsupportedDirectiveBlock.cs | 9 +- .../Myst/Directives/VersionBlock.cs | 13 +- .../Myst/FrontMatter/FrontMatterParser.cs | 22 - .../DiagnosticLinkInlineParser.cs | 4 +- src/Elastic.Markdown/Myst/MarkdownParser.cs | 22 +- src/Elastic.Markdown/Myst/ParserContext.cs | 2 +- .../Myst/Settings/StructuredSettings.cs | 63 ++ .../Myst/YamlSerialization.cs | 39 + .../Slices/Directives/Settings.cshtml | 29 + .../Slices/Directives/_ViewModels.cs | 9 + .../SettingsInclusion/IncludeTests.cs | 61 ++ 28 files changed, 1216 insertions(+), 105 deletions(-) create mode 100644 docs/source/elastic/reference/kibana-alerting-action-settings.yml create mode 100644 src/Elastic.Markdown/Myst/Directives/SettingsBlock.cs create mode 100644 src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs create mode 100644 src/Elastic.Markdown/Myst/YamlSerialization.cs create mode 100644 src/Elastic.Markdown/Slices/Directives/Settings.cshtml create mode 100644 tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs diff --git a/docs/source/elastic/reference/index.md b/docs/source/elastic/reference/index.md index 55ebb6c..c7d049c 100644 --- a/docs/source/elastic/reference/index.md +++ b/docs/source/elastic/reference/index.md @@ -2,10 +2,7 @@ title: Automated Settings Reference --- -Elastic docs v3 supports automatically generated configuration documentation OOTB. -Simply supply a yaml spec and corresponding template file and content will be automatically built and updated. -This section includes one example yaml file and two auto-generated outputs based on that file: -* [example `yaml` file](source.md) -* [generated output](generated.md) \ No newline at end of file +```{settings} kibana-alerting-action-settings.yml +``` diff --git a/docs/source/elastic/reference/kibana-alerting-action-settings.yml b/docs/source/elastic/reference/kibana-alerting-action-settings.yml new file mode 100644 index 0000000..8fe9670 --- /dev/null +++ b/docs/source/elastic/reference/kibana-alerting-action-settings.yml @@ -0,0 +1,749 @@ +--- +# This file is used to generate "Alert and action settings" page in the product docs + +product: Kibana +collection: Alerting and action settings in Kibana + +groups: + - group: General settings + id: general-alert-action-settings + settings: + - setting: xpack.encryptedSavedObjects.encryptionKey + description: | + A string of 32 or more characters used to encrypt sensitive properties on alerting rules and actions before they're stored in Elasticsearch. Third party credentials — such as the username and password used to connect to an SMTP service — are an example of encrypted properties. + Kibana offers a <> to help generate this encryption key. + If not set, Kibana will generate a random key on startup, but all alerting and action functions will be blocked. Generated keys are not allowed for alerting and actions because when a new key is generated on restart, existing encrypted data becomes inaccessible. For the same reason, alerting and actions in high-availability deployments of Kibana will behave unexpectedly if the key isn't the same on all instances of Kibana. + Although the key can be specified in clear text in `kibana.yml`, it's recommended to store this key securely in the <>. Be sure to back up the encryption key value somewhere safe, as your alerting rules and actions will cease to function due to decryption failures should you lose it. If you want to rotate the encryption key, be sure to follow the instructions on <>. + + - group: Action settings + id: action-settings + settings: + - setting: xpack.actions.allowedHosts + description: | + A list of hostnames that Kibana is allowed to connect to when built-in actions are triggered. It defaults to `["*"]`, allowing any host, but keep in mind the potential for SSRF attacks when hosts are not explicitly added to the allowed hosts. An empty list `[]` can be used to block built-in actions from making any external connections. + Note that hosts associated with built-in actions, such as Slack and PagerDuty, are not automatically added to allowed hosts. If you are not using the default `["*"]` setting, you must ensure that the corresponding endpoints are added to the allowed hosts as well. + platforms: + - cloud + + - setting: xpack.actions.customHostSettings + description: | + A list of custom host settings to override existing global settings. + Each entry in the list must have a `url` property, to associate a connection type (mail or https), hostname and port with the remaining options in the entry. + The settings in `xpack.actions.customHostSettings` can be used to override the global option `xpack.actions.ssl.verificationMode` and provide customized TLS settings on a per-server basis. Set `xpack.actions.ssl.verificationMode` to the value to be used by default for all servers, then add an entry in `xpack.actions.customHostSettings` for every server that requires customized settings. + default: an empty list + platforms: + - cloud + example: | + In the following example, two custom host settings + are defined. The first provides a custom host setting for mail server + `mail.example.com` using port 465 that supplies server certificate authentication + data from both a file and inline, and requires TLS for the + connection. The second provides a custom host setting for https server + `webhook.example.com` which turns off server certificate authentication, + that will allow Kibana to connect to the server if it's using a self-signed + certificate. The individual properties that can be used in the settings are + documented below. + + [source,yaml] + -- + xpack.actions.customHostSettings: + - url: smtp://mail.example.com:465 + ssl: + verificationMode: 'full' + certificateAuthoritiesFiles: [ 'one.crt' ] + certificateAuthoritiesData: | + -----BEGIN CERTIFICATE----- + MIIDTD... + CwUAMD... + ... multiple lines of certificate data ... + -----END CERTIFICATE----- + smtp: + requireTLS: true + - url: https://webhook.example.com + ssl: + verificationMode: 'none' + -- + + - setting: xpack.actions.customHostSettings[n].url + description: | + - "A URL associated with this custom host setting. Should be in the form of `protocol://hostname:port`, where `protocol` is `https` or `smtp`. If the port is not provided, 443 is used for `https` and 25 is used for `smtp`. The `smtp` URLs are used for the Email actions that use this server, and the `https` URLs are used for actions which use `https` to connect to services." + - "Entries with `https` URLs can use the `ssl` options, and entries with `smtp` URLs can use both the `ssl` and `smtp` options." + - "No other URL values should be part of this URL, including paths, query strings, and authentication information. When an http or smtp request is made as part of running an action, only the protocol, hostname, and port of the URL for that request are used to look up these configuration values." + platforms: + - cloud + + - setting: xpack.actions.customHostSettings[n].smtp.ignoreTLS + description: | + - "A boolean value indicating that TLS must not be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true." + default: false + platforms: + - cloud + + - setting: xpack.actions.customHostSettings[n].smtp.requireTLS + description: | + - "A boolean value indicating that TLS must be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true." + default: false + platforms: + - cloud + + - setting: xpack.actions.customHostSettings[n].ssl.verificationMode + id: action-config-custom-host-verification-mode + description: | + - "Controls the verification of the server certificate that Kibana receives when making an outbound SSL/TLS connection to the host server. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification. Default: `full`. <>. Overrides the general `xpack.actions.ssl.verificationMode` configuration for requests made for this hostname/port." + platforms: + - cloud + + - setting: xpack.actions.customHostSettings[n].ssl.certificateAuthoritiesFiles + description: | + - "A file name or list of file names of PEM-encoded certificate files to use to validate the server." + + - setting: xpack.actions.customHostSettings[n].ssl.certificateAuthoritiesData + description: | + - "The contents of one or more PEM-encoded certificate files in multiline format. This configuration can be used for environments where the files cannot be made available." + platforms: + - cloud + + - setting: xpack.actions.email.domain_allowlist + id: action-config-email-domain-allowlist + description: | + - "A list of allowed email domains which can be used with the email connector. When this setting is not used, all email domains are allowed. When this setting is used, if any email is attempted to be sent that (a) includes an addressee with an email domain that is not in the allowlist, or (b) includes a from address domain that is not in the allowlist, it will fail with a message indicating the email is not allowed." + warning: "This feature is available in Kibana 7.17.4 and 8.3.0 onwards but is not supported in Kibana 8.0, 8.1 or 8.2. As such, this setting should be removed before upgrading from 7.17 to 8.0, 8.1 or 8.2. It is possible to configure the settings in 7.17.4 and then upgrade to 8.3.0 directly." + platforms: + - cloud + + - setting: xpack.actions.enableFooterInEmail + description: | + - "A boolean value indicating that a footer with a relevant link should be added to emails sent as alerting actions." + default: true + platforms: + - cloud + + - setting: xpack.actions.enabledActionTypes + description: | + - 'A list of action types that are enabled. It defaults to `["*"]`, enabling all types. The names for built-in Kibana action types are prefixed with a `.` and include: `.email`, `.index`, `.jira`, `.opsgenie`, `.pagerduty`, `.resilient`, `.server-log`, `.servicenow`, .`servicenow-itom`, `.servicenow-sir`, `.slack`, `.swimlane`, `.teams`, `.tines`, `.torq`, `.xmatters`, `.gen-ai`, `.bedrock`, `.gemini`, `.d3security`, and `.webhook`. An empty list `[]` will disable all action types.' + - "Disabled action types will not appear as an option when creating new connectors, but existing connectors and actions of that type will remain in Kibana and will not function." + important: "<> are not affected by this setting." + platforms: + - cloud + + - setting: xpack.actions.microsoftExchangeUrl + description: | + - "The URL for the Microsoft Azure Active Directory endpoint to use for MS Exchange email authentication." + default: https://login.microsoftonline.com + + - setting: xpack.actions.microsoftGraphApiUrl + description: | + - "The URL for the Microsoft Graph API endpoint to use for MS Exchange email authentication." + default: https://graph.microsoft.com/v1.0 + + - setting: xpack.actions.microsoftGraphApiScope + description: | + - "The URL for the Microsoft Graph API scope endpoint to use for MS Exchange email authentication." + default: https://graph.microsoft.com/.default + + - setting: xpack.actions.proxyUrl + description: | + - "Specifies the proxy URL to use, if using a proxy for actions. By default, no proxy is used." + - 'Proxies may be used to proxy http or https requests through a proxy using the http or https protocol. Kibana only uses proxies in "CONNECT" mode (sometimes referred to as "tunneling" TCP mode, compared to HTTP mode). That is, Kibana will always make requests through a proxy using the HTTP `CONNECT` method.' + - "If your proxy is using the https protocol (vs the http protocol), the setting `xpack.actions.ssl.proxyVerificationMode: none` will likely be needed, unless your proxy's certificates are signed using a publicly available certificate authority." + - "There is currently no support for using basic authentication with a proxy (authentication for the proxy itself, not the URL being requested through the proxy)." + platforms: + - cloud + example: | + To help diagnose problems using a proxy, you can use the `curl` command with options to use your proxy, and log debug information, with the following command, replacing the proxy and target URLs as appropriate. This will force the request to be made to the + proxy in tunneling mode, and display some of the interaction between the client and the proxy. + + [source,sh] + -- + curl --verbose --proxytunnel --proxy http://localhost:8080 http://example.com + -- + + - setting: xpack.actions.proxyBypassHosts + description: | + - "Specifies hostnames which should not use the proxy, if using a proxy for actions. The value is an array of hostnames as strings." + - "By default, all hosts will use the proxy, but if an action's hostname is in this list, the proxy will not be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time." + platforms: + - cloud + example: | + For example: + + [source,yaml] + ---- + xpack.actions.proxyBypassHosts: [ "events.pagerduty.com" ] + ---- + + If applicable, include the subdomain in the hostname + + - setting: xpack.actions.proxyOnlyHosts + description: | + - "Specifies hostnames which should only use the proxy, if using a proxy for actions. The value is an array of hostnames as strings." + - "By default, no hosts will use the proxy, but if an action's hostname is in this list, the proxy will be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time." + platforms: + - cloud + example: | + For example: + + [source,yaml] + ---- + xpack.actions.proxyOnlyHosts: [ "events.pagerduty.com" ] + ---- + + If applicable, include the subdomain in the hostname + + - setting: xpack.actions.proxyHeaders + + description: | + - "Specifies HTTP headers for the proxy, if using a proxy for actions." + default: '{}' + platforms: + - cloud + + - setting: xpack.actions.ssl.proxyVerificationMode + id: action-config-proxy-verification-mode + description: | + - "Controls the verification for the proxy server certificate that Kibana receives when making an outbound SSL/TLS connection to the proxy server." + - "Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification." + - "<>" + default: full + options: + - option: full + - option: certificate + - option: none + platforms: + - cloud + + - setting: xpack.actions.ssl.verificationMode + id: action-config-verification-mode + description: | + - "Controls the verification for the server certificate that Elastic Maps Server receives when making an outbound SSL/TLS connection for actions. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification." + - "<>" + - "This setting can be overridden for specific URLs by using the setting `xpack.actions.customHostSettings[n].ssl.verificationMode` (described above) to a different value." + default: full + options: + - option: full + - option: certificate + - option: none + platforms: + - cloud + + - setting: xpack.actions.maxResponseContentLength + description: | + - "Specifies the max number of bytes of the http response for requests to external resources." + default: 1000000 (1MB) + platforms: + - cloud + + - setting: xpack.actions.responseTimeout + description: | + - "Specifies the time allowed for requests to external resources. Requests that take longer are canceled. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `60s`." + platforms: + - cloud + + - setting: xpack.actions.run.maxAttempts + + description: | + - "Specifies the maximum number of times an action can be attempted to run." + options: + - option: minimum 1 and maximum 10 + platforms: + - cloud + + - setting: xpack.actions.run.connectorTypeOverrides + description: | + - "Overrides the configs under `xpack.actions.run` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects." + platforms: + - cloud + example: | + For example: + + [source,yaml] + -- + xpack.actions.run: + maxAttempts: 1 + connectorTypeOverrides: + - id: '.server-log' + maxAttempts: 5 + -- + + - setting: xpack.actions.queued.max + description: | + - "Specifies the maximum number of actions that can be queued." + default: 1000000 + platforms: + - cloud + + - group: Preconfigured connector settings + id: preconfigured-connector-settings + description: | + - "These settings vary depending on which type of preconfigured connector you're adding." + example: | + For example: + + [source,yaml] + ---------------------------------------- + xpack.actions.preconfigured: + my-server-log: + name: preconfigured-server-log-connector-type + actionTypeId: .server-log + ---------------------------------------- + + For more examples, go to <>. + + settings: + + - setting: xpack.actions.preconfiguredAlertHistoryEsIndex + description: | + - "Enables a preconfigured alert history Elasticsearch <> connector." + default: false + platforms: + - cloud + + - setting: xpack.actions.preconfigured + description: | + - "Specifies configuration details that are specific to the type of preconfigured connector." + + - setting: xpack.actions.preconfigured..actionTypeId + description: | + - "The type of preconfigured connector." + options: + - option: .email + - option: .index + - option: .opsgenie + - option: .server-log + - option: .resilient + - option: .slack + - option: .webhook + + - setting: xpack.actions.preconfigured..config + description: | + - "The configuration details, which are specific to the type of preconfigured connector." + + - setting: xpack.actions.preconfigured..config.apiProvider + + description: | + - "For a <>, specifies the OpenAI API provider." + + options: + - option: OpenAI + - option: Azure OpenAI + + - setting: xpack.actions.preconfigured..config.apiUrl + description: | + - "A configuration URL that varies by connector:" + - "* For an <>, specifies the {bedrock} request URL." + - "* For an <>, specifies the {gemini} request URL." + - "* For a <>, specifies the OpenAI request URL." + - "* For a <>, specifies the {ibm-r} instance URL." + - "* For a <>, specifies the Jira instance URL." + - "* For an <>, specifies the {opsgenie} URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`." + - "* For a <>, specifies the PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`." + - "* For a <>, <>, or <> specifies the ServiceNow instance URL." + - "* For a <>, specifies the {swimlane} instance URL." + + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..config.appId + description: | + - "An application ID that varies by connector:" + - "* For a <>, specifies a {swimlane} application identifier." + + - setting: xpack.actions.preconfigured..config.clientId + description: | + - "A client identifier that varies by connector:" + - "* For an <>, specifies a GUID format value that corresponds to the client ID, which is a part of OAuth 2.0 client credentials authentication." + - "* For a <>, <>, or <> specifies the client identifier assigned to the OAuth application." + + - setting: xpack.actions.preconfigured..config.configUrl + description: | + - "For an <> with basic authentication, specifies the request URL for the Elastic Alerts trigger in xMatters." + + - setting: xpack.actions.preconfigured..config.createCommentJson + description: | + - "For a <>, specifies a stringified JSON payload with Mustache variables that is sent to the create comment URL to create a case comment. The required variable is `case.description`." + note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." + + - setting: xpack.actions.preconfigured..config.createCommentMethod + description: | + - "For a <>, specifies the REST API HTTP request method to create a case comment in the third-party system." + default: put + options: + - option: post + - option: put + - option: patch + + - setting: xpack.actions.preconfigured..config.createCommentUrl + description: | + - "For a <>, specifies a REST API URL string to create a case comment by ID in the third-party system." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..config.createIncidentJson + description: | + - "For a <>, specifies a stringified JSON payload with Mustache variables that is sent to the create case URL to create a case. Required variables are `case.title` and `case.description`." + + note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." + + - setting: xpack.actions.preconfigured..config.createIncidentMethod + description: | + - "For a <>, specifies the REST API HTTP request method to create a case in the third-party system" + + default: post + options: + - option: post + - option: put + - option: patch + + - setting: xpack.actions.preconfigured..config.createIncidentUrl + description: | + - "For a <>, specifies a REST API URL string to create a case in the third-party system." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..config.createIncidentResponseKey + description: | + - "For a <>, specifies a string from the response body of the create case method that corresponds to the external service identifier." + + - setting: xpack.actions.preconfigured..config.defaultModel + description: | + - "The default model to use for requests, which varies by connector:" + - "* For an <>, current support is for the Anthropic Claude models. Defaults to `anthropic.claude-3-5-sonnet-20240620-v1:0`." + - "* For a <>, current support is for the Gemini models. Defaults to `gemini-1.5-pro-002`." + - "* For a <>, it is optional and applicable only when `xpack.actions.preconfigured..config.apiProvider` is `OpenAI`." + + - setting: xpack.actions.preconfigured..config.executionTimeField + description: | + - "For an <>, a field that indicates when the document was indexed." + + - setting: xpack.actions.preconfigured..config.from + description: | + - "For an <>, specifies the from address for all emails sent by the connector. It must be specified in `user@host-name` format." + + - setting: xpack.actions.preconfigured..config.getIncidentResponseExternalTitleKey + description: | + - "For a <>, specifies a string from the response body of the get case method that corresponds to the external service title." + + - setting: xpack.actions.preconfigured..config.getIncidentUrl + description: | + - "For a <>, specifies a REST API URL string with an external service ID Mustache variable to get the case from the third-party system." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts. " + + - setting: xpack.actions.preconfigured..config.hasAuth + description: | + - "For an <>, <>, or <>, specifies whether a user and password are required inside the secrets configuration." + default: true + + - setting: xpack.actions.preconfigured..config.headers + description: | + - "For a <> or <>, specifies a set of key-value pairs sent as headers with the request." + + - setting: xpack.actions.preconfigured..config.host + description: | + - "For an <>, specifies the host name of the service provider." + + - setting: xpack.actions.preconfigured..config.index + description: | + - "For an <>, specifies the Elasticsearch index." + + - setting: xpack.actions.preconfigured..config.isOAuth + description: | + - "For a <>, <>, or <>, specifies whether to use basic or OAuth authentication." + + - setting: xpack.actions.preconfigured..config.jwtKeyId + description: | + - "For a <>, <>, or <>, specifies the key ID assigned to the JWT verifier map of your OAuth application. It is required when `xpack.actions.preconfigured..config.isOAuth` is `true`." + + - setting: xpack.actions.preconfigured..config.mappings + description: | + - "For a <>, specifies field mappings." + + - setting: xpack.actions.preconfigured..config.mappings.alertIdConfig + description: | + - "For a <>, field mapping for the alert identifier. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.caseIdConfig + description: | + - "For a <>, field mapping for the case identifier. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.caseNameConfig + description: | + - "For a <>, field mapping for the case name. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.commentsConfig + description: | + - "For a <>, field mapping for the case comments. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.descriptionConfig + description: | + - "For a <>, field mapping for the case description. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.ruleNameConfig + description: | + - "For a <>, field mapping for the rule name. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.mappings.severityConfig + description: | + - "For a <>, specifies a field mapping for the severity. You must provide `fieldtype`, `id`, `key`, and `name` values." + + - setting: xpack.actions.preconfigured..config.method + description: | + - "For a <>, specifies the HTTP request method, either `post` or `put`. Defaults to `post`." + + - setting: xpack.actions.preconfigured..config.orgId + description: | + - "For an <>, specifies the {ibm-r} organization identifier." + + - setting: xpack.actions.preconfigured..config.port + description: | + - "For an <>, specifies the port to connect to on the service provider." + + - setting: xpack.actions.preconfigured..config.projectKey + description: | + - "For a <>, specifies the Jira project key." + + - setting: xpack.actions.preconfigured..config.secure + description: | + - "For an <>, specifies whether the connection will use TLS when connecting to the service provider. If not true, the connection will initially connect over TCP then attempt to switch to TLS via the SMTP STARTTLS command." + + - setting: xpack.actions.preconfigured..config.service + description: | + - "For an <>, specifies the name of the email service. For example, `elastic_cloud`, `exchange_server`, `gmail`, `other`, `outlook365`, or `ses`." + + - setting: xpack.actions.preconfigured..config.tenantId + description: | + - "For an <>, specifies a GUID format value that corresponds to a tenant ID, which is a part of OAuth 2.0 client credentials authentication." + + - setting: xpack.actions.preconfigured..config.updateIncidentJson + description: | + - "For a <>, specifies a stringified JSON payload with Mustache variables that is sent to the update case URL to update a case. Required variables are `case.title` and `case.description`." + + note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." + + - setting: xpack.actions.preconfigured..config.updateIncidentMethod + description: | + - "For a <>, specifies the REST API HTTP request method to update the case in the third-party system." + default: put + options: + - option: post + - option: put + - option: patch + + - setting: xpack.actions.preconfigured..config.updateIncidentUrl + description: | + - "For a <>, specifies the REST API URL to update the case by ID in the third-party system." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..config.url + description: | + - "A configuration URL that varies by connector:" + - "* For a <>, specifies the D3 Security API request URL." + - "* For a <>, specifies the Tines tenant URL." + - "* For a <>, specifies the web service request URL." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure this hostname is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..config.userIdentifierValue + description: | + - "For a <>, <>, or <>, specifies the user identifier. It is required when required when `xpack.actions.preconfigured..config.isOAuth` is `true`." + + - setting: xpack.actions.preconfigured..config.usesBasic + description: | + - "For an <>, specifies whether it uses HTTP basic authentication." + default: true + + - setting: xpack.actions.preconfigured..config.usesTableApi + description: | + - "For a <> or <>, specifies whether the connector uses the Table API or the Import Set API. If set to `false`, the Elastic application should be installed in ServiceNow." + + - setting: xpack.actions.preconfigured..config.viewIncidentUrl + description: | + - "For a <>, specifies a URL string with either the external service ID or external service title Mustache variable to view a case in the external system." + + - setting: xpack.actions.preconfigured..config.webhookIntegrationUrl + description: | + - "For a <>, specifies the endpoint URL of the Elastic Security integration in Torq." + + - setting: xpack.actions.preconfigured..name + description: | + - "The name of the preconfigured connector." + + - setting: xpack.actions.preconfigured..secrets + description: | + - "Sensitive configuration details, such as username, password, and keys, which are specific to the connector type." + tip: "Sensitive properties, such as passwords, should be stored in the <>." + + - setting: xpack.actions.preconfigured..secrets.accessKey + description: | + - "For an <>, specifies the AWS access key for authentication." + + - setting: xpack.actions.preconfigured..secrets.apikey + description: | + - "An API key secret that varies by connector." + + - setting: xpack.actions.preconfigured..secrets.credentialsJson + description: | + - "For an <>, specifies the GCP service account credentials JSON file for authentication." + - "* For a <>, specifies the OpenAI or Azure OpenAI API key for authentication." + - "* For an <>, specifies the {opsgenie} API authentication key for HTTP basic authentication." + + - setting: xpack.actions.preconfigured..secrets.apiKeyId + description: | + - "For an <>, specifies the authentication key ID for HTTP basic authentication." + + - setting: xpack.actions.preconfigured..secrets.apiKeySecret + description: | + - "For an <>, specifies the authentication key secret for HTTP basic authentication." + + - setting: xpack.actions.preconfigured..secrets.apiToken + description: | + - "For a <> or <>, specifies the API authentication token for HTTP basic authentication." + + - setting: xpack.actions.preconfigured..secrets.clientSecret + description: | + - "A client secret that varies by connector:" + - "* For an <>, specifies the client secret that you generated for your app in the app registration portal. It is required when the email service is `exchange_server`, which uses OAuth 2.0 client credentials authentication." + - "* For a <>, <>, or <>, specifies the client secret assigned to the OAuth application. It is required when `xpack.actions.preconfigured..config.isOAuth` is `true`." + + note: "The client secret must be URL-encoded." + + - setting: xpack.actions.preconfigured..secrets.email + description: | + - "An email address that varies by connector:" + - "* For a <>, specifies the account email for HTTP basic authentication." + - "* For a <>, specifies the email used to sign in to Tines." + + - setting: xpack.actions.preconfigured..secrets.password + description: | + - "A password secret that varies by connector:" + - "* For an <>, <>, or <>, specifies a password that is required when `xpack.actions.preconfigured..config.hasAuth` is `true`." + - "* For a <>, <>, or <>, specifies a password that is required when `xpack.actions.preconfigured..config.isOAuth` is `false`." + - "* For an <>, specifies a password that is required when `xpack.actions.preconfigured..config.usesBasic` is `true`." + + - setting: xpack.actions.preconfigured..secrets.privateKey + description: | + - "For a <>, <>, or <>, specifies the RSA private key. It is required when `xpack.actions.preconfigured..config.isOAuth` is `true`." + + - setting: xpack.actions.preconfigured..secrets.privateKeyPassword + description: | + - "For a <>, <>, or <>, specifies the password for the RSA private key." + + - setting: xpack.actions.preconfigured..secrets.routingKey + description: | + - "For a <>, specifies the 32 character PagerDuty Integration Key for an integration on a service, also referred to as the routing key." + + - setting: xpack.actions.preconfigured..secrets.secret + description: | + - "For an <>, specifies the AWS secret for authentication." + + - setting: xpack.actions.preconfigured..secrets.secretsUrl + description: | + - "For an <> with URL authentication, specifies the request URL for the Elastic Alerts trigger in xMatters with the API key included in the URL. It is used only when `xpack.actions.preconfigured..config.usesBasic` is `false`." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure this hostname is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..secrets.token + description: | + - "A token secret that varies by connector:" + - "* For a <>, specifies the D3 Security token." + - "* For a <>, specifies the Slack bot user OAuth token." + - "* For a <>, specifies the Tines API token." + - "* For a <>, specifies the secret of the webhook authentication header." + + - setting: xpack.actions.preconfigured..secrets.user + description: | + - "A user name secret that varies by connector:" + - "* For an <>, <>, or <>, specifies a user name that is required when `xpack.actions.preconfigured..config.hasAuth` is `true`." + - "* For an <>, specifies a user name that is required when `xpack.actions.preconfigured..config.usesBasic` is `true`." + + - setting: xpack.actions.preconfigured..secrets.webhookUrl + description: | + - "A URL that varies by connector:" + - "* For a <>, specifies the URL of the incoming webhook." + - "* For a <>, specifies the Slack webhook URL." + note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname is added to the allowed hosts." + + - setting: xpack.actions.preconfigured..secrets.username + description: | + - "For a <>, <>, or <>, specifies a user name that is required when `xpack.actions.preconfigured..config.isOAuth` is `false`." + + - group: Alerting settings + id: alert-settings + + settings: + + - setting: xpack.alerting.cancelAlertsOnRuleTimeout + description: | + - "Specifies whether to skip writing alerts and scheduling actions if rule processing was cancelled due to a timeout. This setting can be overridden by individual rule types." + default: true + platforms: + - cloud + + - setting: xpack.alerting.rules.maxScheduledPerMinute + description: | + - "Specifies the maximum number of rules to run per minute." + default: 10000 + + - setting: xpack.alerting.rules.minimumScheduleInterval.value + description: | + - "Specifies the minimum schedule interval for rules. This minimum is applied to all rules created or updated after you set this value. The time is formatted as a number and a time unit (`s`, `m`, `h`, or `d`). For example, `20m`, `24h`, `7d`. This duration cannot exceed `1d`." + default: 1m + platforms: + - cloud + + - setting: xpack.alerting.rules.minimumScheduleInterval.enforce + description: | + - "Specifies the behavior when a new or changed rule has a schedule interval less than the value defined in `xpack.alerting.rules.minimumScheduleInterval.value`. If `false`, rules with schedules less than the interval will be created but warnings will be logged. If `true`, rules with schedules less than the interval cannot be created." + default: false + platforms: + - cloud + + - setting: xpack.alerting.rules.run.actions.max + description: | + - "Specifies the maximum number of actions that a rule can generate each time detection checks run." + + platforms: + - cloud + + - setting: xpack.alerting.rules.run.alerts.max + description: | + - "Specifies the maximum number of alerts that a rule can generate each time detection checks run." + warning: "The exact number of alerts your cluster can safely handle depends on your cluster configuration and workload, however setting a value higher than the default (`1000`) is not recommended or supported. Doing so could strain system resources and lead to performance issues, delays in alert processing, and potential disruptions during high alert activity periods." + default: 1000 + platforms: + - cloud + + - setting: xpack.alerting.rules.run.timeout + description: | + - "Specifies the default timeout for tasks associated with all types of rules. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `5m`." + platforms: + - cloud + + - setting: xpack.alerting.rules.run.ruleTypeOverrides + description: | + - "Overrides the configs under `xpack.alerting.rules.run` for the rule type with the given ID. List the rule identifier and its settings in an array of objects." + platforms: + - cloud + example: | + For example: + + [source,yaml] + -- + xpack.alerting.rules.run: + timeout: '5m' + ruleTypeOverrides: + - id: '.index-threshold' + timeout: '15m' + -- + + - setting: xpack.alerting.rules.run.actions.connectorTypeOverrides + description: | + - "Overrides the configs under `xpack.alerting.rules.run.actions` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects." + platforms: + - cloud + example: | + For example: + + [source,yaml] + -- + xpack.alerting.rules.run: + actions: + max: 10 + connectorTypeOverrides: + - id: '.server-log' + max: 5 + -- \ No newline at end of file diff --git a/docs/source/markup/substitutions.md b/docs/source/markup/substitutions.md index c38718b..23318c2 100644 --- a/docs/source/markup/substitutions.md +++ b/docs/source/markup/substitutions.md @@ -2,14 +2,16 @@ title: Substitutions sub: frontmatter_key: "Front Matter Value" + a-key-with-dashes: "A key with dashes" version: 7.17.0 --- Here are some variable substitutions: -| Value | Source | -| ------------------- | ------------ | -| {{frontmatter_key}} | Front Matter | +| Variable | Defined in | +|-----------------------|--------------| +| {{frontmatter_key}} | Front Matter | +| {{a-key-with-dashes}} | Front Matter | Substitutions should work in code blocks too. @@ -20,3 +22,6 @@ shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 <1> tar -xzf elasticsearch-{{version}}-linux-x86_64.tar.gz cd elasticsearch-{{version}}/ <2> ``` + + +Here is a variable with dashes: {{a-key-with-dashes}} diff --git a/src/Elastic.Markdown/Diagnostics/ProcessorDiagnosticExtensions.cs b/src/Elastic.Markdown/Diagnostics/ProcessorDiagnosticExtensions.cs index f61176f..c2f690c 100644 --- a/src/Elastic.Markdown/Diagnostics/ProcessorDiagnosticExtensions.cs +++ b/src/Elastic.Markdown/Diagnostics/ProcessorDiagnosticExtensions.cs @@ -4,6 +4,7 @@ using System.IO.Abstractions; using Elastic.Markdown.Myst; +using Elastic.Markdown.Myst.Directives; using Markdig.Helpers; using Markdig.Parsers; @@ -44,7 +45,7 @@ public static void EmitWarning(this InlineProcessor processor, int line, int col context.Build.Collector.Channel.Write(d); } - public static void EmitError(this ParserContext context, int line, int column, int length, string message) + public static void EmitError(this ParserContext context, int line, int column, int length, string message, Exception? e = null) { if (context.SkipValidation) return; var d = new Diagnostic @@ -53,7 +54,7 @@ public static void EmitError(this ParserContext context, int line, int column, i File = context.Path.FullName, Column = column, Line = line, - Message = message, + Message = message + (e != null ? Environment.NewLine + e : string.Empty), Length = length }; context.Build.Collector.Channel.Write(d); @@ -74,13 +75,13 @@ public static void EmitWarning(this ParserContext context, int line, int column, context.Build.Collector.Channel.Write(d); } - public static void EmitError(this BuildContext context, IFileInfo file, string message) + public static void EmitError(this BuildContext context, IFileInfo file, string message, Exception? e = null) { var d = new Diagnostic { Severity = Severity.Error, File = file.FullName, - Message = message, + Message = message + (e != null ? Environment.NewLine + e : string.Empty), }; context.Collector.Channel.Write(d); } @@ -89,10 +90,42 @@ public static void EmitWarning(this BuildContext context, IFileInfo file, string { var d = new Diagnostic { - Severity = Severity.Error, + Severity = Severity.Warning, File = file.FullName, Message = message, }; context.Collector.Channel.Write(d); } + + public static void EmitError(this DirectiveBlock block, string message, Exception? e = null) + { + if (block.SkipValidation) return; + + var d = new Diagnostic + { + Severity = Severity.Error, + File = block.CurrentFile.FullName, + Line = block.Line + 1, + Column = block.Column, + Length = block.Directive.Length + 5, + Message = message + (e != null ? Environment.NewLine + e : string.Empty), + }; + block.Build.Collector.Channel.Write(d); + } + + public static void EmitWarning(this DirectiveBlock block, string message) + { + if (block.SkipValidation) return; + + var d = new Diagnostic + { + Severity = Severity.Warning, + File = block.CurrentFile.FullName, + Line = block.Line + 1, + Column = block.Column, + Length = block.Directive.Length + 4, + Message = message + }; + block.Build.Collector.Channel.Write(d); + } } diff --git a/src/Elastic.Markdown/IO/MarkdownFile.cs b/src/Elastic.Markdown/IO/MarkdownFile.cs index 477b619..e1df97a 100644 --- a/src/Elastic.Markdown/IO/MarkdownFile.cs +++ b/src/Elastic.Markdown/IO/MarkdownFile.cs @@ -75,7 +75,7 @@ private void ReadDocumentInstructions(MarkdownDocument document) if (document.FirstOrDefault() is YamlFrontMatterBlock yaml) { var raw = string.Join(Environment.NewLine, yaml.Lines.Lines); - YamlFrontMatter = FrontMatterParser.Deserialize(raw); + YamlFrontMatter = YamlSerialization.Deserialize(raw); Title = YamlFrontMatter.Title; NavigationTitle = YamlFrontMatter.NavigationTitle; } diff --git a/src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs b/src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs index 39f43e0..d6f1894 100644 --- a/src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs @@ -3,8 +3,12 @@ // See the LICENSE file in the project root for more information namespace Elastic.Markdown.Myst.Directives; -public class AdmonitionBlock(DirectiveBlockParser parser, string admonition, Dictionary properties) - : DirectiveBlock(parser, properties) +public class AdmonitionBlock( + DirectiveBlockParser parser, + string admonition, + Dictionary properties, + ParserContext context) + : DirectiveBlock(parser, properties, context) { public string Admonition => admonition == "admonition" ? Classes?.Trim() ?? "note" : admonition; @@ -36,8 +40,8 @@ public override void FinalizeAndValidate(ParserContext context) } -public class DropdownBlock(DirectiveBlockParser parser, Dictionary properties) - : AdmonitionBlock(parser, "admonition", properties) +public class DropdownBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : AdmonitionBlock(parser, "admonition", properties, context) { // ReSharper disable once RedundantOverriddenMember public override void FinalizeAndValidate(ParserContext context) diff --git a/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs b/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs index f475034..afcd7a3 100644 --- a/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs @@ -2,13 +2,14 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using Elastic.Markdown.Diagnostics; using Elastic.Markdown.Myst.FrontMatter; using Markdig.Syntax; namespace Elastic.Markdown.Myst.Directives; -public class AppliesBlock(DirectiveBlockParser parser, Dictionary properties) - : DirectiveBlock(parser, properties) +public class AppliesBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => "mermaid"; @@ -48,7 +49,7 @@ public override void FinalizeAndValidate(ParserContext context) } if (Deployment is null) - EmitError(context, "{applies} block with no product availability specified"); + this.EmitError("{applies} block with no product availability specified"); var index = Parent?.IndexOf(this); if (Parent is not null && index > 0) @@ -56,7 +57,7 @@ public override void FinalizeAndValidate(ParserContext context) var i = index - 1 ?? 0; var prevSib = Parent[i]; if (prevSib is not HeadingBlock) - EmitError(context, "{applies} should follow a heading"); + this.EmitError("{applies} should follow a heading"); } bool TryGetAvailability(string key, out ProductAvailability? semVersion) diff --git a/src/Elastic.Markdown/Myst/Directives/CodeBlock.cs b/src/Elastic.Markdown/Myst/Directives/CodeBlock.cs index 3d6be14..b76ed7e 100644 --- a/src/Elastic.Markdown/Myst/Directives/CodeBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/CodeBlock.cs @@ -3,8 +3,12 @@ // See the LICENSE file in the project root for more information namespace Elastic.Markdown.Myst.Directives; -public class CodeBlock(DirectiveBlockParser parser, string directive, Dictionary properties) - : DirectiveBlock(parser, properties) +public class CodeBlock( + DirectiveBlockParser parser, + string directive, + Dictionary properties, + ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => directive; public string? Caption { get; private set; } diff --git a/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs b/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs index d18e0b4..cc4d624 100644 --- a/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs @@ -5,6 +5,7 @@ // This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. +using System.IO.Abstractions; using Elastic.Markdown.Diagnostics; using Markdig.Helpers; using Markdig.Syntax; @@ -22,10 +23,22 @@ namespace Elastic.Markdown.Myst.Directives; /// The parser used to create this block. /// /// -public abstract class DirectiveBlock(DirectiveBlockParser parser, Dictionary properties) +public abstract class DirectiveBlock( + DirectiveBlockParser parser, + Dictionary properties, + ParserContext context + ) : ContainerBlock(parser), IFencedBlock { - public IReadOnlyDictionary Properties { get; } = properties; + protected IReadOnlyDictionary Properties { get; } = properties; + + public BuildContext Build { get; } = context.Build; + + public IFileInfo CurrentFile { get; } = context.Path; + + public bool SkipValidation { get; } = context.SkipValidation; + + public abstract string Directive { get; } public string? CrossReferenceName { get; protected set; } @@ -91,13 +104,4 @@ protected bool PropBool(params string[] keys) return default; } - public abstract string Directive { get; } - - protected void EmitError(ParserContext context, string message) => - context.EmitError(Line + 1, 1, Directive.Length + 4 , message); - - protected void EmitWarning(ParserContext context, string message) => - context.EmitWarning(Line + 1, 1, Directive.Length + 4 , message); - - } diff --git a/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs b/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs index ee0e393..852937d 100644 --- a/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs +++ b/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs @@ -74,21 +74,21 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor) throw new Exception("Expected parser context to be of type ParserContext"); if (info.IndexOf("{") == -1) - return new CodeBlock(this, "raw", _admonitionData); + return new CodeBlock(this, "raw", _admonitionData, context); // TODO alternate lookup .NET 9 var directive = info.ToString().Trim(['{', '}', '`']); if (_unsupportedBlocks.TryGetValue(directive, out var issueId)) - return new UnsupportedDirectiveBlock(this, directive, _admonitionData, issueId); + return new UnsupportedDirectiveBlock(this, directive, _admonitionData, issueId, context); if (info.IndexOf("{tab-set}") > 0) - return new TabSetBlock(this, _admonitionData); + return new TabSetBlock(this, _admonitionData, context); if (info.IndexOf("{tab-item}") > 0) - return new TabItemBlock(this, _admonitionData); + return new TabItemBlock(this, _admonitionData, context); if (info.IndexOf("{dropdown}") > 0) - return new DropdownBlock(this, _admonitionData); + return new DropdownBlock(this, _admonitionData, context); if (info.IndexOf("{image}") > 0) return new ImageBlock(this, _admonitionData, context); @@ -103,7 +103,7 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor) // leaving the parsing in until we are confident we don't want this // for dev-docs if (info.IndexOf("{mermaid}") > 0) - return new MermaidBlock(this, _admonitionData); + return new MermaidBlock(this, _admonitionData, context); if (info.IndexOf("{include}") > 0) return new IncludeBlock(this, _admonitionData, context); @@ -112,26 +112,29 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor) return new LiteralIncludeBlock(this, _admonitionData, context); if (info.IndexOf("{applies}") > 0) - return new AppliesBlock(this, _admonitionData); + return new AppliesBlock(this, _admonitionData, context); + + if (info.IndexOf("{settings}") > 0) + return new SettingsBlock(this, _admonitionData, context); foreach (var admonition in _admonitions) { if (info.IndexOf($"{{{admonition}}}") > 0) - return new AdmonitionBlock(this, admonition, _admonitionData); + return new AdmonitionBlock(this, admonition, _admonitionData, context); } foreach (var version in _versionBlocks) { if (info.IndexOf($"{{{version}}}") > 0) - return new VersionBlock(this, version, _admonitionData); + return new VersionBlock(this, version, _admonitionData, context); } foreach (var code in _codeBlocks) { if (info.IndexOf($"{{{code}}}") > 0) - return new CodeBlock(this, code, _admonitionData); + return new CodeBlock(this, code, _admonitionData, context); } - return new UnknownDirectiveBlock(this, info.ToString(), _admonitionData); + return new UnknownDirectiveBlock(this, info.ToString(), _admonitionData, context); } public override bool Close(BlockProcessor processor, Block block) diff --git a/src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs b/src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs index 9a815a2..df88297 100644 --- a/src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs +++ b/src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs @@ -5,18 +5,18 @@ // This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. +using Elastic.Markdown.Diagnostics; using Elastic.Markdown.Myst.FrontMatter; +using Elastic.Markdown.Myst.Settings; using Elastic.Markdown.Myst.Substitution; -using Elastic.Markdown.Slices; using Elastic.Markdown.Slices.Directives; using Markdig; -using Markdig.Extensions.Figures; using Markdig.Renderers; using Markdig.Renderers.Html; using Markdig.Syntax; using Markdig.Syntax.Inlines; using RazorSlices; -using YamlDotNet.Serialization.EventEmitters; +using YamlDotNet.Core; namespace Elastic.Markdown.Myst.Directives; @@ -71,6 +71,9 @@ protected override void Write(HtmlRenderer renderer, DirectiveBlock directiveBlo else WriteIncludeBlock(renderer, includeBlock); return; + case SettingsBlock settingsBlock: + WriteSettingsBlock(renderer, settingsBlock); + return; default: // if (!string.IsNullOrEmpty(directiveBlock.Info) && !directiveBlock.Info.StartsWith('{')) // WriteCode(renderer, directiveBlock); @@ -225,7 +228,7 @@ private void WriteIncludeBlock(HtmlRenderer renderer, IncludeBlock block) if (!block.Found || block.IncludePath is null) return; - var parser = new MarkdownParser(block.DocumentationSourcePath, block.Build, block.GetMarkdownFile, + var parser = new MarkdownParser(block.DocumentationSourcePath, block.Build, block.GetDocumentationFile, block.Configuration); var file = block.FileSystem.FileInfo.New(block.IncludePath); var document = parser.ParseAsync(file, block.FrontMatter, default).GetAwaiter().GetResult(); @@ -235,6 +238,45 @@ private void WriteIncludeBlock(HtmlRenderer renderer, IncludeBlock block) //RenderRazorSlice(slice, renderer, block); } + private void WriteSettingsBlock(HtmlRenderer renderer, SettingsBlock block) + { + if (!block.Found || block.IncludePath is null) + return; + + var parser = new MarkdownParser(block.DocumentationSourcePath, block.Build, block.GetDocumentationFile, block.Configuration); + + var file = block.FileSystem.FileInfo.New(block.IncludePath); + + SettingsCollection? settings; + try + { + var yaml = file.FileSystem.File.ReadAllText(file.FullName); + settings = YamlSerialization.Deserialize(yaml); + } + catch (YamlException e) + { + block.EmitError("Can not be parsed as a valid settings file", e.InnerException ?? e); + return; + } + catch (Exception e) + { + block.EmitError("Can not be parsed as a valid settings file", e); + return; + } + + var slice = Slices.Directives.Settings.Create(new SettingsViewModel + { + SettingsCollection = settings, + RenderMarkdown = s => + { + var document = parser.Parse(s, block.IncludeFrom, block.FrontMatter); + var html = document.ToHtml(parser.Pipeline); + return html; + } + }); + RenderRazorSliceNoContent(slice, renderer); + } + private static void RenderRazorSlice(RazorSlice slice, HtmlRenderer renderer, string contents) { var html = slice.RenderAsync().GetAwaiter().GetResult(); diff --git a/src/Elastic.Markdown/Myst/Directives/ImageBlock.cs b/src/Elastic.Markdown/Myst/Directives/ImageBlock.cs index ba4651c..6fc805c 100644 --- a/src/Elastic.Markdown/Myst/Directives/ImageBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/ImageBlock.cs @@ -1,15 +1,16 @@ // Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information + +using Elastic.Markdown.Diagnostics; + namespace Elastic.Markdown.Myst.Directives; public class ImageBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) - : DirectiveBlock(parser, properties) + : DirectiveBlock(parser, properties, context) { public override string Directive => "image"; - public BuildContext Build { get; } = context.Build; - /// /// Alternate text: a short description of the image, displayed by applications that cannot display images, /// or spoken by applications for visually impaired users. @@ -73,13 +74,13 @@ private void ExtractImageUrl(ParserContext context) var imageUrl = Arguments; if (string.IsNullOrWhiteSpace(imageUrl)) { - EmitError(context , $"{Directive} requires an argument."); + this.EmitError($"{Directive} requires an argument."); return; } if (Uri.TryCreate(imageUrl, UriKind.Absolute, out var uri) && uri.Scheme.StartsWith("http")) { - EmitWarning(context, $"{Directive} is using an external URI: {uri} "); + this.EmitWarning($"{Directive} is using an external URI: {uri} "); Found = true; ImageUrl = imageUrl; return; @@ -94,7 +95,7 @@ private void ExtractImageUrl(ParserContext context) if (context.Build.ReadFileSystem.File.Exists(imagePath)) Found = true; else - EmitError(context, $"`{imageUrl}` does not exist. resolved to `{imagePath}"); + this.EmitError($"`{imageUrl}` does not exist. resolved to `{imagePath}"); } } diff --git a/src/Elastic.Markdown/Myst/Directives/IncludeBlock.cs b/src/Elastic.Markdown/Myst/Directives/IncludeBlock.cs index 28dd4c5..b55e820 100644 --- a/src/Elastic.Markdown/Myst/Directives/IncludeBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/IncludeBlock.cs @@ -9,13 +9,11 @@ namespace Elastic.Markdown.Myst.Directives; public class IncludeBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) - : DirectiveBlock(parser, properties) + : DirectiveBlock(parser, properties, context) { public override string Directive => "include"; - public BuildContext Build { get; } = context.Build; - - public Func? GetMarkdownFile { get; } = context.GetMarkdownFile; + public Func? GetDocumentationFile { get; } = context.GetDocumentationFile; public ConfigurationFile Configuration { get; } = context.Configuration; @@ -64,7 +62,7 @@ private void ExtractInclusionPath(ParserContext context) if (FileSystem.File.Exists(IncludePath)) Found = true; else - EmitError(context, $"`{IncludePath}` does not exist."); + this.EmitError($"`{IncludePath}` does not exist."); } } diff --git a/src/Elastic.Markdown/Myst/Directives/MermaidBlock.cs b/src/Elastic.Markdown/Myst/Directives/MermaidBlock.cs index 73fd0d4..7452bde 100644 --- a/src/Elastic.Markdown/Myst/Directives/MermaidBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/MermaidBlock.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information namespace Elastic.Markdown.Myst.Directives; -public class MermaidBlock(DirectiveBlockParser parser, Dictionary properties) - : DirectiveBlock(parser, properties) +public class MermaidBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => "mermaid"; diff --git a/src/Elastic.Markdown/Myst/Directives/SettingsBlock.cs b/src/Elastic.Markdown/Myst/Directives/SettingsBlock.cs new file mode 100644 index 0000000..6b9c36d --- /dev/null +++ b/src/Elastic.Markdown/Myst/Directives/SettingsBlock.cs @@ -0,0 +1,61 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information +using System.IO.Abstractions; +using Elastic.Markdown.Diagnostics; +using Elastic.Markdown.IO; +using Elastic.Markdown.Myst.FrontMatter; + +namespace Elastic.Markdown.Myst.Directives; + +public class SettingsBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : DirectiveBlock(parser, properties, context) +{ + public override string Directive => "settings"; + + public Func? GetDocumentationFile { get; } = context.GetDocumentationFile; + + public ConfigurationFile Configuration { get; } = context.Configuration; + + public IFileSystem FileSystem { get; } = context.Build.ReadFileSystem; + + public IFileInfo IncludeFrom { get; } = context.Path; + + public IDirectoryInfo DocumentationSourcePath { get; } = context.Parser.SourcePath; + + public YamlFrontMatter? FrontMatter { get; } = context.FrontMatter; + + public string? IncludePath { get; private set; } + + public bool Found { get; private set; } + + + //TODO add all options from + //https://mystmd.org/guide/directives#directive-include + public override void FinalizeAndValidate(ParserContext context) + { + ExtractInclusionPath(context); + } + + private void ExtractInclusionPath(ParserContext context) + { + var includePath = Arguments; + if (string.IsNullOrWhiteSpace(includePath)) + { + this.EmitError("include requires an argument."); + return; + } + + var includeFrom = context.Path.Directory!.FullName; + if (includePath.StartsWith('/')) + includeFrom = DocumentationSourcePath.FullName; + + IncludePath = Path.Combine(includeFrom, includePath.TrimStart('/')); + if (FileSystem.File.Exists(IncludePath)) + Found = true; + else + this.EmitError($"`{IncludePath}` does not exist."); + } +} + + diff --git a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs index b5dbe9c..75db2fd 100644 --- a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs @@ -2,10 +2,12 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using Elastic.Markdown.Diagnostics; + namespace Elastic.Markdown.Myst.Directives; -public class TabSetBlock(DirectiveBlockParser parser, Dictionary properties) - : DirectiveBlock(parser, properties) +public class TabSetBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => "tab-set"; @@ -21,8 +23,8 @@ public int FindIndex() return _index; } } -public class TabItemBlock(DirectiveBlockParser parser, Dictionary properties) - : DirectiveBlock(parser, properties) +public class TabItemBlock(DirectiveBlockParser parser, Dictionary properties, ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => "tab-item"; @@ -36,7 +38,7 @@ public class TabItemBlock(DirectiveBlockParser parser, Dictionary properties) - : DirectiveBlock(parser, properties) +public class UnknownDirectiveBlock( + DirectiveBlockParser parser, + string directive, + Dictionary properties, + ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => directive; diff --git a/src/Elastic.Markdown/Myst/Directives/UnsupportedDirectiveBlock.cs b/src/Elastic.Markdown/Myst/Directives/UnsupportedDirectiveBlock.cs index 47cbef9..6f3345c 100644 --- a/src/Elastic.Markdown/Myst/Directives/UnsupportedDirectiveBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/UnsupportedDirectiveBlock.cs @@ -6,8 +6,13 @@ namespace Elastic.Markdown.Myst.Directives; -public class UnsupportedDirectiveBlock(DirectiveBlockParser parser, string directive, Dictionary properties, int issueId) - : DirectiveBlock(parser, properties) +public class UnsupportedDirectiveBlock( + DirectiveBlockParser parser, + string directive, + Dictionary properties, + int issueId, + ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => directive; diff --git a/src/Elastic.Markdown/Myst/Directives/VersionBlock.cs b/src/Elastic.Markdown/Myst/Directives/VersionBlock.cs index 9fda232..e03feaa 100644 --- a/src/Elastic.Markdown/Myst/Directives/VersionBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/VersionBlock.cs @@ -2,13 +2,18 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using Elastic.Markdown.Diagnostics; using Elastic.Markdown.Helpers; using static System.StringSplitOptions; namespace Elastic.Markdown.Myst.Directives; -public class VersionBlock(DirectiveBlockParser parser, string directive, Dictionary properties) - : DirectiveBlock(parser, properties) +public class VersionBlock( + DirectiveBlockParser parser, + string directive, + Dictionary properties, + ParserContext context) + : DirectiveBlock(parser, properties, context) { public override string Directive => directive; public string Class => directive.Replace("version", ""); @@ -21,7 +26,7 @@ public override void FinalizeAndValidate(ParserContext context) var tokens = Arguments?.Split(" ", 2, RemoveEmptyEntries) ?? []; if (tokens.Length < 1) { - EmitError(context, $"{directive} needs exactly 2 arguments: "); + this.EmitError($"{directive} needs exactly 2 arguments: <version> <title>"); return; } @@ -29,7 +34,7 @@ public override void FinalizeAndValidate(ParserContext context) { var numbers = tokens[0].Split('.', RemoveEmptyEntries); if (numbers.Length != 2 || !SemVersion.TryParse($"{numbers[0]}.{numbers[1]}.0", out version)) - EmitError(context, $"'{tokens[0]}' is not a valid version"); + this.EmitError($"'{tokens[0]}' is not a valid version"); } Version = version; diff --git a/src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs b/src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs index 694045a..cdedbd4 100644 --- a/src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs +++ b/src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs @@ -6,9 +6,6 @@ namespace Elastic.Markdown.Myst.FrontMatter; -[YamlStaticContext] -public partial class YamlFrontMatterStaticContext; - [YamlSerializable] public class YamlFrontMatter { @@ -25,22 +22,3 @@ public class YamlFrontMatter [YamlMember(Alias = "applies")] public Deployment? AppliesTo { get; set; } } - -public static class FrontMatterParser -{ - public static YamlFrontMatter Deserialize(string yaml) - { - var input = new StringReader(yaml); - - var deserializer = new StaticDeserializerBuilder(new YamlFrontMatterStaticContext()) - .IgnoreUnmatchedProperties() - .WithTypeConverter(new SemVersionConverter()) - .WithTypeConverter(new DeploymentConverter()) - .Build(); - - var frontMatter = deserializer.Deserialize<YamlFrontMatter>(input); - return frontMatter; - - } -} - diff --git a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs index d4ce66d..d7e3fa1 100644 --- a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs +++ b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs @@ -3,12 +3,14 @@ // See the LICENSE file in the project root for more information using Elastic.Markdown.Diagnostics; +using Elastic.Markdown.IO; using Elastic.Markdown.Myst.Directives; using Markdig; using Markdig.Helpers; using Markdig.Parsers; using Markdig.Parsers.Inlines; using Markdig.Renderers; +using Markdig.Syntax; using Markdig.Syntax.Inlines; namespace Elastic.Markdown.Myst.InlineParsers; @@ -88,7 +90,7 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice) { var file = string.IsNullOrWhiteSpace(url) ? context.Path : context.Build.ReadFileSystem.FileInfo.New(Path.Combine(context.Build.SourcePath.FullName, url.TrimStart('/'))); - var markdown = context.GetMarkdownFile?.Invoke(file); + var markdown = context.GetDocumentationFile?.Invoke(file) as MarkdownFile; var title = markdown?.Title; if (!string.IsNullOrEmpty(anchor)) diff --git a/src/Elastic.Markdown/Myst/MarkdownParser.cs b/src/Elastic.Markdown/Myst/MarkdownParser.cs index 9fccbc7..ee3ff9d 100644 --- a/src/Elastic.Markdown/Myst/MarkdownParser.cs +++ b/src/Elastic.Markdown/Myst/MarkdownParser.cs @@ -19,11 +19,12 @@ namespace Elastic.Markdown.Myst; public class MarkdownParser( IDirectoryInfo sourcePath, BuildContext context, - Func<IFileInfo, MarkdownFile?>? getMarkdownFile, + Func<IFileInfo, DocumentationFile?>? getDocumentationFile, ConfigurationFile configuration) { public IDirectoryInfo SourcePath { get; } = sourcePath; - public BuildContext Context { get; } = context; + + private BuildContext Context { get; } = context; //TODO directive properties are stateful, rewrite this so we can cache builders public MarkdownPipeline MinimalPipeline => @@ -51,13 +52,12 @@ public class MarkdownParser( .DisableHtml() .Build(); - public Task<MarkdownDocument> MinimalParseAsync(IFileInfo path, Cancel ctx) { var context = new ParserContext(this, path, null, Context, configuration) { SkipValidation = true, - GetMarkdownFile = getMarkdownFile + GetDocumentationFile = getDocumentationFile }; return ParseAsync(path, context, MinimalPipeline, ctx); } @@ -66,7 +66,7 @@ public Task<MarkdownDocument> ParseAsync(IFileInfo path, YamlFrontMatter? matter { var context = new ParserContext(this, path, matter, Context, configuration) { - GetMarkdownFile = getMarkdownFile + GetDocumentationFile = getDocumentationFile }; return ParseAsync(path, context, Pipeline, ctx); } @@ -92,4 +92,16 @@ private async Task<MarkdownDocument> ParseAsync( return markdownDocument; } } + + public MarkdownDocument Parse(string yaml, IFileInfo parent, YamlFrontMatter? matter) + { + var context = new ParserContext(this, parent, matter, Context, configuration) + { + GetDocumentationFile = getDocumentationFile + }; + var markdownDocument = Markdig.Markdown.Parse(yaml, Pipeline, context); + return markdownDocument; + } + + } diff --git a/src/Elastic.Markdown/Myst/ParserContext.cs b/src/Elastic.Markdown/Myst/ParserContext.cs index 9f07cab..bce31cc 100644 --- a/src/Elastic.Markdown/Myst/ParserContext.cs +++ b/src/Elastic.Markdown/Myst/ParserContext.cs @@ -57,5 +57,5 @@ public ParserContext(MarkdownParser markdownParser, public YamlFrontMatter? FrontMatter { get; } public BuildContext Build { get; } public bool SkipValidation { get; init; } - public Func<IFileInfo, MarkdownFile?>? GetMarkdownFile { get; init; } + public Func<IFileInfo, DocumentationFile?>? GetDocumentationFile { get; init; } } diff --git a/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs b/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs new file mode 100644 index 0000000..afce6d3 --- /dev/null +++ b/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs @@ -0,0 +1,63 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +using Elastic.Markdown.Myst.FrontMatter; +using YamlDotNet.Serialization; + +namespace Elastic.Markdown.Myst.Settings; + +[YamlSerializable] +public record SettingsCollection +{ + [YamlMember(Alias = "product")] + public string? Product { get; set; } + [YamlMember(Alias = "collection")] + public string? Collection { get; set; } + [YamlMember(Alias = "groups")] + public SettingsGrouping[] Groups { get; set; } = []; +} + +[YamlSerializable] +public record SettingsGrouping +{ + [YamlMember(Alias = "group")] + public string? Name { get; set; } + [YamlMember(Alias = "self")] + public string? Id { get; set; } + [YamlMember(Alias = "settings")] + public Setting[] Settings { get; set; } = []; +} + +[YamlSerializable] +public record Setting +{ + [YamlMember(Alias = "setting")] + public string? Name { get; set; } + [YamlMember(Alias = "description")] + public string? Description { get; set; } + [YamlMember(Alias = "applies")] + public ProductAvailability? Applies { get; set; } + [YamlMember(Alias = "type")] + public SettingMutability Mutability { get; set; } + [YamlMember(Alias = "options")] + public AllowedValue[]? Options { get; set; } +} + +[YamlSerializable] +public record AllowedValue +{ + [YamlMember(Alias = "option")] + public string? Option { get; set; } + [YamlMember(Alias = "description")] + public string? Description { get; set; } +} + +[YamlSerializable] +public enum SettingMutability +{ + [YamlMember(Alias = "static")] + Static, + [YamlMember(Alias = "dynamic")] + Dynamic +} diff --git a/src/Elastic.Markdown/Myst/YamlSerialization.cs b/src/Elastic.Markdown/Myst/YamlSerialization.cs new file mode 100644 index 0000000..472407d --- /dev/null +++ b/src/Elastic.Markdown/Myst/YamlSerialization.cs @@ -0,0 +1,39 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +using Elastic.Markdown.Myst.FrontMatter; +using Elastic.Markdown.Myst.Settings; +using YamlDotNet.Serialization; + +namespace Elastic.Markdown.Myst; + +public static class YamlSerialization +{ + public static T Deserialize<T>(string yaml) + { + var input = new StringReader(yaml); + + var deserializer = new StaticDeserializerBuilder(new DocsBuilderYamlStaticContext()) + .IgnoreUnmatchedProperties() + .WithTypeConverter(new SemVersionConverter()) + .WithTypeConverter(new DeploymentConverter()) + .Build(); + + var frontMatter = deserializer.Deserialize<T>(input); + return frontMatter; + + } +} + +[YamlStaticContext] +[YamlSerializable(typeof(SettingsCollection))] +[YamlSerializable(typeof(SettingsGrouping))] +[YamlSerializable(typeof(SettingsCollection))] +[YamlSerializable(typeof(SettingsGrouping))] +[YamlSerializable(typeof(Setting))] +[YamlSerializable(typeof(AllowedValue))] +[YamlSerializable(typeof(SettingMutability))] + +public partial class DocsBuilderYamlStaticContext; + diff --git a/src/Elastic.Markdown/Slices/Directives/Settings.cshtml b/src/Elastic.Markdown/Slices/Directives/Settings.cshtml new file mode 100644 index 0000000..0b2bbbf --- /dev/null +++ b/src/Elastic.Markdown/Slices/Directives/Settings.cshtml @@ -0,0 +1,29 @@ +@using Elastic.Markdown.Myst.FrontMatter +@using Elastic.Markdown.Myst.Settings +@inherits RazorSlice<SettingsViewModel> + +@foreach (var group in Model.SettingsCollection.Groups) +{ + @RenderGroup(group) +} +@functions { + + private IHtmlContent RenderGroup(SettingsGrouping group) + { + <h2>@group.Name</h2> + foreach (var setting in group.Settings) + { + @RenderSetting(setting) + } + return HtmlString.Empty; + } + private IHtmlContent RenderSetting(Setting setting) + { + <h4>@setting.Name</h4> + if (setting.Description is not null) + { + @(new HtmlString(Model.RenderMarkdown(setting.Description))) + } + return HtmlString.Empty; + } +} diff --git a/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs b/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs index 759fdc3..2bb9344 100644 --- a/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs +++ b/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs @@ -2,6 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information using System.Text; +using Elastic.Markdown.Myst.Settings; namespace Elastic.Markdown.Slices.Directives; @@ -65,4 +66,12 @@ public string Style } } + +public class SettingsViewModel +{ + public required SettingsCollection SettingsCollection { get; init; } + + public required Func<string, string> RenderMarkdown { get; init; } +} + public class MermaidViewModel; diff --git a/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs b/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs new file mode 100644 index 0000000..afbeb91 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs @@ -0,0 +1,61 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +using System.IO.Abstractions.TestingHelpers; +using Elastic.Markdown.Diagnostics; +using Elastic.Markdown.Myst.Directives; +using Elastic.Markdown.Tests.Directives; +using FluentAssertions; +using Xunit.Abstractions; + +namespace Elastic.Markdown.Tests.SettingsInclusion; + +public class IncludeTests(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output, +""" +```{settings} _snippets/test.md +``` +""" +) +{ + protected override void AddToFileSystem(MockFileSystem fileSystem) + { + // language=markdown + var inclusion = "*Hello world*"; + fileSystem.AddFile(@"docs/source/_snippets/test.md", inclusion); + } + + [Fact] + public void ParsesBlock() => Block.Should().NotBeNull(); + + [Fact] + public void IncludesInclusionHtml() => + Html.Should() + .Contain("Hello world") + .And.Be("<p><em>Hello world</em></p>\n") + ; +} +public class RandomFileEmitsAnError(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output, +""" +```{settings} _snippets/test.md +``` +""" +) +{ + protected override void AddToFileSystem(MockFileSystem fileSystem) + { + // language=markdown + var inclusion = "*Hello world*"; + fileSystem.AddFile(@"docs/source/_snippets/test.md", inclusion); + } + + [Fact] + public void EmitsError() + { + Collector.Diagnostics.Should().NotBeNullOrEmpty().And.HaveCount(1); + Collector.Diagnostics.Should().OnlyContain(d => d.Severity == Severity.Error); + Collector.Diagnostics.FirstOrDefault().File.Should().NotEndWith("test.md"); + Collector.Diagnostics.Should() + .OnlyContain(d => d.Message.Contains("Can not be parsed as a valid settings file")); + } +} From b868a4adc46564275966dcd928da8f63edc33408 Mon Sep 17 00:00:00 2001 From: Martijn Laarman <Mpdreamz@gmail.com> Date: Mon, 16 Dec 2024 16:45:21 +0100 Subject: [PATCH 2/3] Fix test to ensure it loads a valid yaml test file and asserts its output --- .../kibana-alerting-action-settings.yml | 1 + .../SettingsInclusion/IncludeTests.cs | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/source/elastic/reference/kibana-alerting-action-settings.yml b/docs/source/elastic/reference/kibana-alerting-action-settings.yml index 8fe9670..7f41b41 100644 --- a/docs/source/elastic/reference/kibana-alerting-action-settings.yml +++ b/docs/source/elastic/reference/kibana-alerting-action-settings.yml @@ -33,6 +33,7 @@ groups: default: an empty list platforms: - cloud + # language=markdown example: | In the following example, two custom host settings are defined. The first provides a custom host setting for mail server diff --git a/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs b/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs index afbeb91..e093a8e 100644 --- a/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs +++ b/tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs @@ -4,6 +4,7 @@ using System.IO.Abstractions.TestingHelpers; using Elastic.Markdown.Diagnostics; +using Elastic.Markdown.IO; using Elastic.Markdown.Myst.Directives; using Elastic.Markdown.Tests.Directives; using FluentAssertions; @@ -12,28 +13,33 @@ namespace Elastic.Markdown.Tests.SettingsInclusion; public class IncludeTests(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output, -""" -```{settings} _snippets/test.md +$$""" +```{settings} /{{SettingsPath.Replace("docs/source/", "")}} ``` """ ) { + private static readonly string SettingsPath = + "docs/source/elastic/reference/kibana-alerting-action-settings.yml"; + protected override void AddToFileSystem(MockFileSystem fileSystem) { + var realSettingsPath = Path.Combine(Paths.Root.FullName, SettingsPath); // language=markdown - var inclusion = "*Hello world*"; - fileSystem.AddFile(@"docs/source/_snippets/test.md", inclusion); + var inclusion = System.IO.File.ReadAllText(realSettingsPath); + fileSystem.AddFile(SettingsPath, inclusion); } [Fact] public void ParsesBlock() => Block.Should().NotBeNull(); + [Fact] + public void HasNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + [Fact] public void IncludesInclusionHtml() => Html.Should() - .Contain("Hello world") - .And.Be("<p><em>Hello world</em></p>\n") - ; + .Contain("xpack.encryptedSavedObjects.encryptionKey"); } public class RandomFileEmitsAnError(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output, """ From 55e30af98c0e29308efb444cadbf06339c91622d Mon Sep 17 00:00:00 2001 From: Martijn Laarman <Mpdreamz@gmail.com> Date: Mon, 16 Dec 2024 17:01:33 +0100 Subject: [PATCH 3/3] replace string arrays inside multiline strings --- .../kibana-alerting-action-settings.yml | 298 +++++++++--------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/docs/source/elastic/reference/kibana-alerting-action-settings.yml b/docs/source/elastic/reference/kibana-alerting-action-settings.yml index 7f41b41..1bf8214 100644 --- a/docs/source/elastic/reference/kibana-alerting-action-settings.yml +++ b/docs/source/elastic/reference/kibana-alerting-action-settings.yml @@ -67,22 +67,22 @@ groups: - setting: xpack.actions.customHostSettings[n].url description: | - - "A URL associated with this custom host setting. Should be in the form of `protocol://hostname:port`, where `protocol` is `https` or `smtp`. If the port is not provided, 443 is used for `https` and 25 is used for `smtp`. The `smtp` URLs are used for the Email actions that use this server, and the `https` URLs are used for actions which use `https` to connect to services." - - "Entries with `https` URLs can use the `ssl` options, and entries with `smtp` URLs can use both the `ssl` and `smtp` options." - - "No other URL values should be part of this URL, including paths, query strings, and authentication information. When an http or smtp request is made as part of running an action, only the protocol, hostname, and port of the URL for that request are used to look up these configuration values." + A URL associated with this custom host setting. Should be in the form of `protocol://hostname:port`, where `protocol` is `https` or `smtp`. If the port is not provided, 443 is used for `https` and 25 is used for `smtp`. The `smtp` URLs are used for the Email actions that use this server, and the `https` URLs are used for actions which use `https` to connect to services. + Entries with `https` URLs can use the `ssl` options, and entries with `smtp` URLs can use both the `ssl` and `smtp` options. + No other URL values should be part of this URL, including paths, query strings, and authentication information. When an http or smtp request is made as part of running an action, only the protocol, hostname, and port of the URL for that request are used to look up these configuration values. platforms: - cloud - setting: xpack.actions.customHostSettings[n].smtp.ignoreTLS description: | - - "A boolean value indicating that TLS must not be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true." + A boolean value indicating that TLS must not be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true. default: false platforms: - cloud - setting: xpack.actions.customHostSettings[n].smtp.requireTLS description: | - - "A boolean value indicating that TLS must be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true." + A boolean value indicating that TLS must be used for this connection. The options `smtp.ignoreTLS` and `smtp.requireTLS` can not both be set to true. default: false platforms: - cloud @@ -90,31 +90,31 @@ groups: - setting: xpack.actions.customHostSettings[n].ssl.verificationMode id: action-config-custom-host-verification-mode description: | - - "Controls the verification of the server certificate that Kibana receives when making an outbound SSL/TLS connection to the host server. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification. Default: `full`. <<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>>. Overrides the general `xpack.actions.ssl.verificationMode` configuration for requests made for this hostname/port." + Controls the verification of the server certificate that Kibana receives when making an outbound SSL/TLS connection to the host server. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification. Default: `full`. <<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>>. Overrides the general `xpack.actions.ssl.verificationMode` configuration for requests made for this hostname/port. platforms: - cloud - setting: xpack.actions.customHostSettings[n].ssl.certificateAuthoritiesFiles description: | - - "A file name or list of file names of PEM-encoded certificate files to use to validate the server." + A file name or list of file names of PEM-encoded certificate files to use to validate the server. - setting: xpack.actions.customHostSettings[n].ssl.certificateAuthoritiesData description: | - - "The contents of one or more PEM-encoded certificate files in multiline format. This configuration can be used for environments where the files cannot be made available." + The contents of one or more PEM-encoded certificate files in multiline format. This configuration can be used for environments where the files cannot be made available. platforms: - cloud - setting: xpack.actions.email.domain_allowlist id: action-config-email-domain-allowlist description: | - - "A list of allowed email domains which can be used with the email connector. When this setting is not used, all email domains are allowed. When this setting is used, if any email is attempted to be sent that (a) includes an addressee with an email domain that is not in the allowlist, or (b) includes a from address domain that is not in the allowlist, it will fail with a message indicating the email is not allowed." + A list of allowed email domains which can be used with the email connector. When this setting is not used, all email domains are allowed. When this setting is used, if any email is attempted to be sent that (a) includes an addressee with an email domain that is not in the allowlist, or (b) includes a from address domain that is not in the allowlist, it will fail with a message indicating the email is not allowed. warning: "This feature is available in Kibana 7.17.4 and 8.3.0 onwards but is not supported in Kibana 8.0, 8.1 or 8.2. As such, this setting should be removed before upgrading from 7.17 to 8.0, 8.1 or 8.2. It is possible to configure the settings in 7.17.4 and then upgrade to 8.3.0 directly." platforms: - cloud - setting: xpack.actions.enableFooterInEmail description: | - - "A boolean value indicating that a footer with a relevant link should be added to emails sent as alerting actions." + A boolean value indicating that a footer with a relevant link should be added to emails sent as alerting actions. default: true platforms: - cloud @@ -122,32 +122,32 @@ groups: - setting: xpack.actions.enabledActionTypes description: | - 'A list of action types that are enabled. It defaults to `["*"]`, enabling all types. The names for built-in Kibana action types are prefixed with a `.` and include: `.email`, `.index`, `.jira`, `.opsgenie`, `.pagerduty`, `.resilient`, `.server-log`, `.servicenow`, .`servicenow-itom`, `.servicenow-sir`, `.slack`, `.swimlane`, `.teams`, `.tines`, `.torq`, `.xmatters`, `.gen-ai`, `.bedrock`, `.gemini`, `.d3security`, and `.webhook`. An empty list `[]` will disable all action types.' - - "Disabled action types will not appear as an option when creating new connectors, but existing connectors and actions of that type will remain in Kibana and will not function." + Disabled action types will not appear as an option when creating new connectors, but existing connectors and actions of that type will remain in Kibana and will not function. important: "<<pre-configured-connectors,Preconfigured connectors>> are not affected by this setting." platforms: - cloud - setting: xpack.actions.microsoftExchangeUrl description: | - - "The URL for the Microsoft Azure Active Directory endpoint to use for MS Exchange email authentication." + The URL for the Microsoft Azure Active Directory endpoint to use for MS Exchange email authentication. default: https://login.microsoftonline.com - setting: xpack.actions.microsoftGraphApiUrl description: | - - "The URL for the Microsoft Graph API endpoint to use for MS Exchange email authentication." + The URL for the Microsoft Graph API endpoint to use for MS Exchange email authentication. default: https://graph.microsoft.com/v1.0 - setting: xpack.actions.microsoftGraphApiScope description: | - - "The URL for the Microsoft Graph API scope endpoint to use for MS Exchange email authentication." + The URL for the Microsoft Graph API scope endpoint to use for MS Exchange email authentication. default: https://graph.microsoft.com/.default - setting: xpack.actions.proxyUrl description: | - - "Specifies the proxy URL to use, if using a proxy for actions. By default, no proxy is used." + Specifies the proxy URL to use, if using a proxy for actions. By default, no proxy is used. - 'Proxies may be used to proxy http or https requests through a proxy using the http or https protocol. Kibana only uses proxies in "CONNECT" mode (sometimes referred to as "tunneling" TCP mode, compared to HTTP mode). That is, Kibana will always make requests through a proxy using the HTTP `CONNECT` method.' - - "If your proxy is using the https protocol (vs the http protocol), the setting `xpack.actions.ssl.proxyVerificationMode: none` will likely be needed, unless your proxy's certificates are signed using a publicly available certificate authority." - - "There is currently no support for using basic authentication with a proxy (authentication for the proxy itself, not the URL being requested through the proxy)." + If your proxy is using the https protocol (vs the http protocol), the setting `xpack.actions.ssl.proxyVerificationMode: none` will likely be needed, unless your proxy's certificates are signed using a publicly available certificate authority. + There is currently no support for using basic authentication with a proxy (authentication for the proxy itself, not the URL being requested through the proxy). platforms: - cloud example: | @@ -161,8 +161,8 @@ groups: - setting: xpack.actions.proxyBypassHosts description: | - - "Specifies hostnames which should not use the proxy, if using a proxy for actions. The value is an array of hostnames as strings." - - "By default, all hosts will use the proxy, but if an action's hostname is in this list, the proxy will not be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time." + Specifies hostnames which should not use the proxy, if using a proxy for actions. The value is an array of hostnames as strings. + By default, all hosts will use the proxy, but if an action's hostname is in this list, the proxy will not be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time. platforms: - cloud example: | @@ -177,8 +177,8 @@ groups: - setting: xpack.actions.proxyOnlyHosts description: | - - "Specifies hostnames which should only use the proxy, if using a proxy for actions. The value is an array of hostnames as strings." - - "By default, no hosts will use the proxy, but if an action's hostname is in this list, the proxy will be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time." + Specifies hostnames which should only use the proxy, if using a proxy for actions. The value is an array of hostnames as strings. + By default, no hosts will use the proxy, but if an action's hostname is in this list, the proxy will be used. The settings `xpack.actions.proxyBypassHosts` and `xpack.actions.proxyOnlyHosts` cannot be used at the same time. platforms: - cloud example: | @@ -194,7 +194,7 @@ groups: - setting: xpack.actions.proxyHeaders description: | - - "Specifies HTTP headers for the proxy, if using a proxy for actions." + Specifies HTTP headers for the proxy, if using a proxy for actions. default: '{}' platforms: - cloud @@ -202,9 +202,9 @@ groups: - setting: xpack.actions.ssl.proxyVerificationMode id: action-config-proxy-verification-mode description: | - - "Controls the verification for the proxy server certificate that Kibana receives when making an outbound SSL/TLS connection to the proxy server." - - "Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification." - - "<<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>>" + Controls the verification for the proxy server certificate that Kibana receives when making an outbound SSL/TLS connection to the proxy server. + Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification. + <<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>> default: full options: - option: full @@ -216,9 +216,9 @@ groups: - setting: xpack.actions.ssl.verificationMode id: action-config-verification-mode description: | - - "Controls the verification for the server certificate that Elastic Maps Server receives when making an outbound SSL/TLS connection for actions. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification." - - "<<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>>" - - "This setting can be overridden for specific URLs by using the setting `xpack.actions.customHostSettings[n].ssl.verificationMode` (described above) to a different value." + Controls the verification for the server certificate that Elastic Maps Server receives when making an outbound SSL/TLS connection for actions. Valid values are `full`, `certificate`, and `none`. Use `full` to perform hostname verification, `certificate` to skip hostname verification, and `none` to skip verification. + <<elasticsearch-ssl-verificationMode,Equivalent Kibana setting>> + This setting can be overridden for specific URLs by using the setting `xpack.actions.customHostSettings[n].ssl.verificationMode` (described above) to a different value. default: full options: - option: full @@ -229,21 +229,21 @@ groups: - setting: xpack.actions.maxResponseContentLength description: | - - "Specifies the max number of bytes of the http response for requests to external resources." + Specifies the max number of bytes of the http response for requests to external resources. default: 1000000 (1MB) platforms: - cloud - setting: xpack.actions.responseTimeout description: | - - "Specifies the time allowed for requests to external resources. Requests that take longer are canceled. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `60s`." + Specifies the time allowed for requests to external resources. Requests that take longer are canceled. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `60s`. platforms: - cloud - setting: xpack.actions.run.maxAttempts description: | - - "Specifies the maximum number of times an action can be attempted to run." + Specifies the maximum number of times an action can be attempted to run. options: - option: minimum 1 and maximum 10 platforms: @@ -251,7 +251,7 @@ groups: - setting: xpack.actions.run.connectorTypeOverrides description: | - - "Overrides the configs under `xpack.actions.run` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects." + Overrides the configs under `xpack.actions.run` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects. platforms: - cloud example: | @@ -268,7 +268,7 @@ groups: - setting: xpack.actions.queued.max description: | - - "Specifies the maximum number of actions that can be queued." + Specifies the maximum number of actions that can be queued. default: 1000000 platforms: - cloud @@ -276,7 +276,7 @@ groups: - group: Preconfigured connector settings id: preconfigured-connector-settings description: | - - "These settings vary depending on which type of preconfigured connector you're adding." + These settings vary depending on which type of preconfigured connector you're adding. example: | For example: @@ -294,18 +294,18 @@ groups: - setting: xpack.actions.preconfiguredAlertHistoryEsIndex description: | - - "Enables a preconfigured alert history Elasticsearch <<index-action-type, Index>> connector." + Enables a preconfigured alert history Elasticsearch <<index-action-type, Index>> connector. default: false platforms: - cloud - setting: xpack.actions.preconfigured description: | - - "Specifies configuration details that are specific to the type of preconfigured connector." + Specifies configuration details that are specific to the type of preconfigured connector. - setting: xpack.actions.preconfigured.<connector-id>.actionTypeId description: | - - "The type of preconfigured connector." + The type of preconfigured connector. options: - option: .email - option: .index @@ -317,12 +317,12 @@ groups: - setting: xpack.actions.preconfigured.<connector-id>.config description: | - - "The configuration details, which are specific to the type of preconfigured connector." + The configuration details, which are specific to the type of preconfigured connector. - setting: xpack.actions.preconfigured.<connector-id>.config.apiProvider description: | - - "For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI API provider." + For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI API provider. options: - option: OpenAI @@ -330,42 +330,42 @@ groups: - setting: xpack.actions.preconfigured.<connector-id>.config.apiUrl description: | - - "A configuration URL that varies by connector:" - - "* For an <<bedrock-action-type,{bedrock} connector>>, specifies the {bedrock} request URL." - - "* For an <<gemini-action-type,{gemini} connector>>, specifies the {gemini} request URL." - - "* For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI request URL." - - "* For a <<resilient-action-type,{ibm-r} connector>>, specifies the {ibm-r} instance URL." - - "* For a <<jira-action-type,Jira connector>>, specifies the Jira instance URL." - - "* For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`." - - "* For a <<pagerduty-action-type,PagerDuty connector>>, specifies the PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`." - - "* For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>> specifies the ServiceNow instance URL." - - "* For a <<swimlane-action-type,{swimlane} connector>>, specifies the {swimlane} instance URL." + A configuration URL that varies by connector: + * For an <<bedrock-action-type,{bedrock} connector>>, specifies the {bedrock} request URL. + * For an <<gemini-action-type,{gemini} connector>>, specifies the {gemini} request URL. + * For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI request URL. + * For a <<resilient-action-type,{ibm-r} connector>>, specifies the {ibm-r} instance URL. + * For a <<jira-action-type,Jira connector>>, specifies the Jira instance URL. + * For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`. + * For a <<pagerduty-action-type,PagerDuty connector>>, specifies the PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`. + * For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>> specifies the ServiceNow instance URL. + * For a <<swimlane-action-type,{swimlane} connector>>, specifies the {swimlane} instance URL. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.config.appId description: | - - "An application ID that varies by connector:" - - "* For a <<swimlane-action-type,{swimlane} connector>>, specifies a {swimlane} application identifier." + An application ID that varies by connector: + * For a <<swimlane-action-type,{swimlane} connector>>, specifies a {swimlane} application identifier. - setting: xpack.actions.preconfigured.<connector-id>.config.clientId description: | - - "A client identifier that varies by connector:" - - "* For an <<email-action-type,email connector>>, specifies a GUID format value that corresponds to the client ID, which is a part of OAuth 2.0 client credentials authentication." - - "* For a <<servicenow-itom-action-type,{sn-itom}>>, <<servicenow-action-type,{sn-itsm}>>, or <<servicenow-sir-action-type,{sn-sir} connector>> specifies the client identifier assigned to the OAuth application." + A client identifier that varies by connector: + * For an <<email-action-type,email connector>>, specifies a GUID format value that corresponds to the client ID, which is a part of OAuth 2.0 client credentials authentication. + * For a <<servicenow-itom-action-type,{sn-itom}>>, <<servicenow-action-type,{sn-itsm}>>, or <<servicenow-sir-action-type,{sn-sir} connector>> specifies the client identifier assigned to the OAuth application. - setting: xpack.actions.preconfigured.<connector-id>.config.configUrl description: | - - "For an <<xmatters-action-type,xMatters connector>> with basic authentication, specifies the request URL for the Elastic Alerts trigger in xMatters." + For an <<xmatters-action-type,xMatters connector>> with basic authentication, specifies the request URL for the Elastic Alerts trigger in xMatters. - setting: xpack.actions.preconfigured.<connector-id>.config.createCommentJson description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the create comment URL to create a case comment. The required variable is `case.description`." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the create comment URL to create a case comment. The required variable is `case.description`. note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." - setting: xpack.actions.preconfigured.<connector-id>.config.createCommentMethod description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to create a case comment in the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to create a case comment in the third-party system. default: put options: - option: post @@ -374,18 +374,18 @@ groups: - setting: xpack.actions.preconfigured.<connector-id>.config.createCommentUrl description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string to create a case comment by ID in the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string to create a case comment by ID in the third-party system. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.config.createIncidentJson description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the create case URL to create a case. Required variables are `case.title` and `case.description`." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the create case URL to create a case. Required variables are `case.title` and `case.description`. note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." - setting: xpack.actions.preconfigured.<connector-id>.config.createIncidentMethod description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to create a case in the third-party system" + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to create a case in the third-party system default: post options: @@ -395,131 +395,131 @@ groups: - setting: xpack.actions.preconfigured.<connector-id>.config.createIncidentUrl description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string to create a case in the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string to create a case in the third-party system. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.config.createIncidentResponseKey description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a string from the response body of the create case method that corresponds to the external service identifier." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a string from the response body of the create case method that corresponds to the external service identifier. - setting: xpack.actions.preconfigured.<connector-id>.config.defaultModel description: | - - "The default model to use for requests, which varies by connector:" - - "* For an <<bedrock-action-type,{bedrock} connector>>, current support is for the Anthropic Claude models. Defaults to `anthropic.claude-3-5-sonnet-20240620-v1:0`." - - "* For a <<gemini-action-type,{gemini} connector>>, current support is for the Gemini models. Defaults to `gemini-1.5-pro-002`." - - "* For a <<openai-action-type,OpenAI connector>>, it is optional and applicable only when `xpack.actions.preconfigured.<connector-id>.config.apiProvider` is `OpenAI`." + The default model to use for requests, which varies by connector: + * For an <<bedrock-action-type,{bedrock} connector>>, current support is for the Anthropic Claude models. Defaults to `anthropic.claude-3-5-sonnet-20240620-v1:0`. + * For a <<gemini-action-type,{gemini} connector>>, current support is for the Gemini models. Defaults to `gemini-1.5-pro-002`. + * For a <<openai-action-type,OpenAI connector>>, it is optional and applicable only when `xpack.actions.preconfigured.<connector-id>.config.apiProvider` is `OpenAI`. - setting: xpack.actions.preconfigured.<connector-id>.config.executionTimeField description: | - - "For an <<index-action-type,index connector>>, a field that indicates when the document was indexed." + For an <<index-action-type,index connector>>, a field that indicates when the document was indexed. - setting: xpack.actions.preconfigured.<connector-id>.config.from description: | - - "For an <<email-action-type,email connector>>, specifies the from address for all emails sent by the connector. It must be specified in `user@host-name` format." + For an <<email-action-type,email connector>>, specifies the from address for all emails sent by the connector. It must be specified in `user@host-name` format. - setting: xpack.actions.preconfigured.<connector-id>.config.getIncidentResponseExternalTitleKey description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a string from the response body of the get case method that corresponds to the external service title." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a string from the response body of the get case method that corresponds to the external service title. - setting: xpack.actions.preconfigured.<connector-id>.config.getIncidentUrl description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string with an external service ID Mustache variable to get the case from the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a REST API URL string with an external service ID Mustache variable to get the case from the third-party system. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts. " - setting: xpack.actions.preconfigured.<connector-id>.config.hasAuth description: | - - "For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies whether a user and password are required inside the secrets configuration." + For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies whether a user and password are required inside the secrets configuration. default: true - setting: xpack.actions.preconfigured.<connector-id>.config.headers description: | - - "For a <<webhook-action-type,webhook>> or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a set of key-value pairs sent as headers with the request." + For a <<webhook-action-type,webhook>> or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a set of key-value pairs sent as headers with the request. - setting: xpack.actions.preconfigured.<connector-id>.config.host description: | - - "For an <<email-action-type,email connector>>, specifies the host name of the service provider." + For an <<email-action-type,email connector>>, specifies the host name of the service provider. - setting: xpack.actions.preconfigured.<connector-id>.config.index description: | - - "For an <<index-action-type,index connector>>, specifies the Elasticsearch index." + For an <<index-action-type,index connector>>, specifies the Elasticsearch index. - setting: xpack.actions.preconfigured.<connector-id>.config.isOAuth description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies whether to use basic or OAuth authentication." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies whether to use basic or OAuth authentication. - setting: xpack.actions.preconfigured.<connector-id>.config.jwtKeyId description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the key ID assigned to the JWT verifier map of your OAuth application. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the key ID assigned to the JWT verifier map of your OAuth application. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings description: | - - "For a <<swimlane-action-type,Swimlane connector>>, specifies field mappings." + For a <<swimlane-action-type,Swimlane connector>>, specifies field mappings. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.alertIdConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the alert identifier. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the alert identifier. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.caseIdConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case identifier. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case identifier. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.caseNameConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case name. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case name. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.commentsConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case comments. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case comments. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.descriptionConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case description. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the case description. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.ruleNameConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, field mapping for the rule name. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, field mapping for the rule name. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.mappings.severityConfig description: | - - "For a <<swimlane-action-type,Swimlane connector>>, specifies a field mapping for the severity. You must provide `fieldtype`, `id`, `key`, and `name` values." + For a <<swimlane-action-type,Swimlane connector>>, specifies a field mapping for the severity. You must provide `fieldtype`, `id`, `key`, and `name` values. - setting: xpack.actions.preconfigured.<connector-id>.config.method description: | - - "For a <<webhook-action-type,webhook connector>>, specifies the HTTP request method, either `post` or `put`. Defaults to `post`." + For a <<webhook-action-type,webhook connector>>, specifies the HTTP request method, either `post` or `put`. Defaults to `post`. - setting: xpack.actions.preconfigured.<connector-id>.config.orgId description: | - - "For an <<resilient-action-type,{ibm-r} connector>>, specifies the {ibm-r} organization identifier." + For an <<resilient-action-type,{ibm-r} connector>>, specifies the {ibm-r} organization identifier. - setting: xpack.actions.preconfigured.<connector-id>.config.port description: | - - "For an <<email-action-type,email connector>>, specifies the port to connect to on the service provider." + For an <<email-action-type,email connector>>, specifies the port to connect to on the service provider. - setting: xpack.actions.preconfigured.<connector-id>.config.projectKey description: | - - "For a <<jira-action-type,Jira connector>>, specifies the Jira project key." + For a <<jira-action-type,Jira connector>>, specifies the Jira project key. - setting: xpack.actions.preconfigured.<connector-id>.config.secure description: | - - "For an <<email-action-type,email connector>>, specifies whether the connection will use TLS when connecting to the service provider. If not true, the connection will initially connect over TCP then attempt to switch to TLS via the SMTP STARTTLS command." + For an <<email-action-type,email connector>>, specifies whether the connection will use TLS when connecting to the service provider. If not true, the connection will initially connect over TCP then attempt to switch to TLS via the SMTP STARTTLS command. - setting: xpack.actions.preconfigured.<connector-id>.config.service description: | - - "For an <<email-action-type,email connector>>, specifies the name of the email service. For example, `elastic_cloud`, `exchange_server`, `gmail`, `other`, `outlook365`, or `ses`." + For an <<email-action-type,email connector>>, specifies the name of the email service. For example, `elastic_cloud`, `exchange_server`, `gmail`, `other`, `outlook365`, or `ses`. - setting: xpack.actions.preconfigured.<connector-id>.config.tenantId description: | - - "For an <<email-action-type,email connector>>, specifies a GUID format value that corresponds to a tenant ID, which is a part of OAuth 2.0 client credentials authentication." + For an <<email-action-type,email connector>>, specifies a GUID format value that corresponds to a tenant ID, which is a part of OAuth 2.0 client credentials authentication. - setting: xpack.actions.preconfigured.<connector-id>.config.updateIncidentJson description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the update case URL to update a case. Required variables are `case.title` and `case.description`." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a stringified JSON payload with Mustache variables that is sent to the update case URL to update a case. Required variables are `case.title` and `case.description`. note: "The JSON is validated after the Mustache variables have been placed when the REST method runs. You should manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass." - setting: xpack.actions.preconfigured.<connector-id>.config.updateIncidentMethod description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to update the case in the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API HTTP request method to update the case in the third-party system. default: put options: - option: post @@ -528,139 +528,139 @@ groups: - setting: xpack.actions.preconfigured.<connector-id>.config.updateIncidentUrl description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API URL to update the case by ID in the third-party system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies the REST API URL to update the case by ID in the third-party system. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname in the URL is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.config.url description: | - - "A configuration URL that varies by connector:" - - "* For a <<d3security-action-type,D3 Security connector>>, specifies the D3 Security API request URL." - - "* For a <<tines-action-type,Tines connector>>, specifies the Tines tenant URL." - - "* For a <<webhook-action-type,webhook connector>>, specifies the web service request URL." + A configuration URL that varies by connector: + * For a <<d3security-action-type,D3 Security connector>>, specifies the D3 Security API request URL. + * For a <<tines-action-type,Tines connector>>, specifies the Tines tenant URL. + * For a <<webhook-action-type,webhook connector>>, specifies the web service request URL. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure this hostname is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.config.userIdentifierValue description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the user identifier. It is required when required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the user identifier. It is required when required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`. - setting: xpack.actions.preconfigured.<connector-id>.config.usesBasic description: | - - "For an <<xmatters-action-type,xMatters connector>>, specifies whether it uses HTTP basic authentication." + For an <<xmatters-action-type,xMatters connector>>, specifies whether it uses HTTP basic authentication. default: true - setting: xpack.actions.preconfigured.<connector-id>.config.usesTableApi description: | - - "For a <<servicenow-action-type,{sn-itsm}>> or <<servicenow-sir-action-type,{sn-sir} connector>>, specifies whether the connector uses the Table API or the Import Set API. If set to `false`, the Elastic application should be installed in ServiceNow." + For a <<servicenow-action-type,{sn-itsm}>> or <<servicenow-sir-action-type,{sn-sir} connector>>, specifies whether the connector uses the Table API or the Import Set API. If set to `false`, the Elastic application should be installed in ServiceNow. - setting: xpack.actions.preconfigured.<connector-id>.config.viewIncidentUrl description: | - - "For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a URL string with either the external service ID or external service title Mustache variable to view a case in the external system." + For a <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a URL string with either the external service ID or external service title Mustache variable to view a case in the external system. - setting: xpack.actions.preconfigured.<connector-id>.config.webhookIntegrationUrl description: | - - "For a <<torq-action-type,Torq connector>>, specifies the endpoint URL of the Elastic Security integration in Torq." + For a <<torq-action-type,Torq connector>>, specifies the endpoint URL of the Elastic Security integration in Torq. - setting: xpack.actions.preconfigured.<connector-id>.name description: | - - "The name of the preconfigured connector." + The name of the preconfigured connector. - setting: xpack.actions.preconfigured.<connector-id>.secrets description: | - - "Sensitive configuration details, such as username, password, and keys, which are specific to the connector type." + Sensitive configuration details, such as username, password, and keys, which are specific to the connector type. tip: "Sensitive properties, such as passwords, should be stored in the <<creating-keystore,Kibana keystore>>." - setting: xpack.actions.preconfigured.<connector-id>.secrets.accessKey description: | - - "For an <<bedrock-action-type,{bedrock} connector>>, specifies the AWS access key for authentication." + For an <<bedrock-action-type,{bedrock} connector>>, specifies the AWS access key for authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.apikey description: | - - "An API key secret that varies by connector." + An API key secret that varies by connector. - setting: xpack.actions.preconfigured.<connector-id>.secrets.credentialsJson description: | - - "For an <<gemini-action-type,{gemini} connector>>, specifies the GCP service account credentials JSON file for authentication." - - "* For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI or Azure OpenAI API key for authentication." - - "* For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} API authentication key for HTTP basic authentication." + For an <<gemini-action-type,{gemini} connector>>, specifies the GCP service account credentials JSON file for authentication. + * For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI or Azure OpenAI API key for authentication. + * For an <<opsgenie-action-type,{opsgenie} connector>>, specifies the {opsgenie} API authentication key for HTTP basic authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.apiKeyId description: | - - "For an <<resilient-action-type,{ibm-r} connector>>, specifies the authentication key ID for HTTP basic authentication." + For an <<resilient-action-type,{ibm-r} connector>>, specifies the authentication key ID for HTTP basic authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.apiKeySecret description: | - - "For an <<resilient-action-type,{ibm-r} connector>>, specifies the authentication key secret for HTTP basic authentication." + For an <<resilient-action-type,{ibm-r} connector>>, specifies the authentication key secret for HTTP basic authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.apiToken description: | - - "For a <<jira-action-type,Jira>> or <<swimlane-action-type,{swimlane} connector>>, specifies the API authentication token for HTTP basic authentication." + For a <<jira-action-type,Jira>> or <<swimlane-action-type,{swimlane} connector>>, specifies the API authentication token for HTTP basic authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.clientSecret description: | - - "A client secret that varies by connector:" - - "* For an <<email-action-type,email connector>>, specifies the client secret that you generated for your app in the app registration portal. It is required when the email service is `exchange_server`, which uses OAuth 2.0 client credentials authentication." - - "* For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the client secret assigned to the OAuth application. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`." + A client secret that varies by connector: + * For an <<email-action-type,email connector>>, specifies the client secret that you generated for your app in the app registration portal. It is required when the email service is `exchange_server`, which uses OAuth 2.0 client credentials authentication. + * For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the client secret assigned to the OAuth application. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`. note: "The client secret must be URL-encoded." - setting: xpack.actions.preconfigured.<connector-id>.secrets.email description: | - - "An email address that varies by connector:" - - "* For a <<jira-action-type,Jira connector>>, specifies the account email for HTTP basic authentication." - - "* For a <<tines-action-type,Tines connector>>, specifies the email used to sign in to Tines." + An email address that varies by connector: + * For a <<jira-action-type,Jira connector>>, specifies the account email for HTTP basic authentication. + * For a <<tines-action-type,Tines connector>>, specifies the email used to sign in to Tines. - setting: xpack.actions.preconfigured.<connector-id>.secrets.password description: | - - "A password secret that varies by connector:" - - "* For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.hasAuth` is `true`." - - "* For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `false`." - - "* For an <<xmatters-action-type,xMatters connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `true`." + A password secret that varies by connector: + * For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.hasAuth` is `true`. + * For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `false`. + * For an <<xmatters-action-type,xMatters connector>>, specifies a password that is required when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `true`. - setting: xpack.actions.preconfigured.<connector-id>.secrets.privateKey description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the RSA private key. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the RSA private key. It is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `true`. - setting: xpack.actions.preconfigured.<connector-id>.secrets.privateKeyPassword description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the password for the RSA private key." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies the password for the RSA private key. - setting: xpack.actions.preconfigured.<connector-id>.secrets.routingKey description: | - - "For a <<pagerduty-action-type,PagerDuty connector>>, specifies the 32 character PagerDuty Integration Key for an integration on a service, also referred to as the routing key." + For a <<pagerduty-action-type,PagerDuty connector>>, specifies the 32 character PagerDuty Integration Key for an integration on a service, also referred to as the routing key. - setting: xpack.actions.preconfigured.<connector-id>.secrets.secret description: | - - "For an <<bedrock-action-type,{bedrock} connector>>, specifies the AWS secret for authentication." + For an <<bedrock-action-type,{bedrock} connector>>, specifies the AWS secret for authentication. - setting: xpack.actions.preconfigured.<connector-id>.secrets.secretsUrl description: | - - "For an <<xmatters-action-type,xMatters connector>> with URL authentication, specifies the request URL for the Elastic Alerts trigger in xMatters with the API key included in the URL. It is used only when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `false`." + For an <<xmatters-action-type,xMatters connector>> with URL authentication, specifies the request URL for the Elastic Alerts trigger in xMatters with the API key included in the URL. It is used only when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `false`. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure this hostname is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.secrets.token description: | - - "A token secret that varies by connector:" - - "* For a <<d3security-action-type,D3 Security conector>>, specifies the D3 Security token." - - "* For a <<slack-action-type,Slack connector>>, specifies the Slack bot user OAuth token." - - "* For a <<tines-action-type,Tines connector>>, specifies the Tines API token." - - "* For a <<torq-action-type,Torq connector>>, specifies the secret of the webhook authentication header." + A token secret that varies by connector: + * For a <<d3security-action-type,D3 Security conector>>, specifies the D3 Security token. + * For a <<slack-action-type,Slack connector>>, specifies the Slack bot user OAuth token. + * For a <<tines-action-type,Tines connector>>, specifies the Tines API token. + * For a <<torq-action-type,Torq connector>>, specifies the secret of the webhook authentication header. - setting: xpack.actions.preconfigured.<connector-id>.secrets.user description: | - - "A user name secret that varies by connector:" - - "* For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.hasAuth` is `true`." - - "* For an <<xmatters-action-type,xMatters connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `true`." + A user name secret that varies by connector: + * For an <<email-action-type,email>>, <<webhook-action-type,webhook>>, or <<cases-webhook-action-type,{webhook-cm} connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.hasAuth` is `true`. + * For an <<xmatters-action-type,xMatters connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.usesBasic` is `true`. - setting: xpack.actions.preconfigured.<connector-id>.secrets.webhookUrl description: | - - "A URL that varies by connector:" - - "* For a <<teams-action-type,Microsoft Teams>>, specifies the URL of the incoming webhook." - - "* For a <<slack-action-type,Slack connector>>, specifies the Slack webhook URL." + A URL that varies by connector: + * For a <<teams-action-type,Microsoft Teams>>, specifies the URL of the incoming webhook. + * For a <<slack-action-type,Slack connector>>, specifies the Slack webhook URL. note: "If you are using the `xpack.actions.allowedHosts` setting, make sure the hostname is added to the allowed hosts." - setting: xpack.actions.preconfigured.<connector-id>.secrets.username description: | - - "For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `false`." + For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir}>>, or <<servicenow-itom-action-type,{sn-itom} connector>>, specifies a user name that is required when `xpack.actions.preconfigured.<connector-id>.config.isOAuth` is `false`. - group: Alerting settings id: alert-settings @@ -669,40 +669,40 @@ groups: - setting: xpack.alerting.cancelAlertsOnRuleTimeout description: | - - "Specifies whether to skip writing alerts and scheduling actions if rule processing was cancelled due to a timeout. This setting can be overridden by individual rule types." + Specifies whether to skip writing alerts and scheduling actions if rule processing was cancelled due to a timeout. This setting can be overridden by individual rule types. default: true platforms: - cloud - setting: xpack.alerting.rules.maxScheduledPerMinute description: | - - "Specifies the maximum number of rules to run per minute." + Specifies the maximum number of rules to run per minute. default: 10000 - setting: xpack.alerting.rules.minimumScheduleInterval.value description: | - - "Specifies the minimum schedule interval for rules. This minimum is applied to all rules created or updated after you set this value. The time is formatted as a number and a time unit (`s`, `m`, `h`, or `d`). For example, `20m`, `24h`, `7d`. This duration cannot exceed `1d`." + Specifies the minimum schedule interval for rules. This minimum is applied to all rules created or updated after you set this value. The time is formatted as a number and a time unit (`s`, `m`, `h`, or `d`). For example, `20m`, `24h`, `7d`. This duration cannot exceed `1d`. default: 1m platforms: - cloud - setting: xpack.alerting.rules.minimumScheduleInterval.enforce description: | - - "Specifies the behavior when a new or changed rule has a schedule interval less than the value defined in `xpack.alerting.rules.minimumScheduleInterval.value`. If `false`, rules with schedules less than the interval will be created but warnings will be logged. If `true`, rules with schedules less than the interval cannot be created." + Specifies the behavior when a new or changed rule has a schedule interval less than the value defined in `xpack.alerting.rules.minimumScheduleInterval.value`. If `false`, rules with schedules less than the interval will be created but warnings will be logged. If `true`, rules with schedules less than the interval cannot be created. default: false platforms: - cloud - setting: xpack.alerting.rules.run.actions.max description: | - - "Specifies the maximum number of actions that a rule can generate each time detection checks run." + Specifies the maximum number of actions that a rule can generate each time detection checks run. platforms: - cloud - setting: xpack.alerting.rules.run.alerts.max description: | - - "Specifies the maximum number of alerts that a rule can generate each time detection checks run." + Specifies the maximum number of alerts that a rule can generate each time detection checks run. warning: "The exact number of alerts your cluster can safely handle depends on your cluster configuration and workload, however setting a value higher than the default (`1000`) is not recommended or supported. Doing so could strain system resources and lead to performance issues, delays in alert processing, and potential disruptions during high alert activity periods." default: 1000 platforms: @@ -710,13 +710,13 @@ groups: - setting: xpack.alerting.rules.run.timeout description: | - - "Specifies the default timeout for tasks associated with all types of rules. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `5m`." + Specifies the default timeout for tasks associated with all types of rules. The time is formatted as a number and a time unit (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `Y`). For example, `20m`, `24h`, `7d`, `1w`. Default: `5m`. platforms: - cloud - setting: xpack.alerting.rules.run.ruleTypeOverrides description: | - - "Overrides the configs under `xpack.alerting.rules.run` for the rule type with the given ID. List the rule identifier and its settings in an array of objects." + Overrides the configs under `xpack.alerting.rules.run` for the rule type with the given ID. List the rule identifier and its settings in an array of objects. platforms: - cloud example: | @@ -733,7 +733,7 @@ groups: - setting: xpack.alerting.rules.run.actions.connectorTypeOverrides description: | - - "Overrides the configs under `xpack.alerting.rules.run.actions` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects." + Overrides the configs under `xpack.alerting.rules.run.actions` for the connector type with the given ID. List the connector type identifier and its settings in an array of objects. platforms: - cloud example: |