Skip to content

Commit 7ba6017

Browse files
authored
Escape special characters in docs (#451)
* Escape wildcard characters in docs * Use escaper * More characters to escape
1 parent ccd0a5e commit 7ba6017

File tree

16 files changed

+54
-49
lines changed

16 files changed

+54
-49
lines changed

internal/docs/exported_fields.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ type fieldsTableRecord struct {
2323
metricType string
2424
}
2525

26+
var escaper = strings.NewReplacer("*", "\\*", "{", "\\{", "}", "\\}", "<", "\\<", ">", "\\>")
27+
2628
func renderExportedFields(packageRoot, dataStreamName string) (string, error) {
2729
dataStreamPath := filepath.Join(packageRoot, "data_stream", dataStreamName)
2830
validator, err := fields.CreateValidatorForDataStream(dataStreamPath)
@@ -70,7 +72,10 @@ func renderFieldsTable(builder *strings.Builder, collected []fieldsTableRecord)
7072
builder.WriteString("\n")
7173
for _, c := range collected {
7274
description := strings.TrimSpace(strings.ReplaceAll(c.description, "\n", " "))
73-
builder.WriteString(fmt.Sprintf("| %s | %s | %s |", c.name, description, c.aType))
75+
builder.WriteString(fmt.Sprintf("| %s | %s | %s |",
76+
escaper.Replace(c.name),
77+
escaper.Replace(description),
78+
c.aType))
7479
if unitsPresent {
7580
builder.WriteString(fmt.Sprintf(" %s |", c.unit))
7681
}

test/packages/aws/docs/billing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ An example event for `billing` looks as following:
6060
| Field | Description | Type |
6161
|---|---|---|
6262
| @timestamp | Event timestamp. | date |
63-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
63+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
6464
| aws.billing.AmortizedCost.amount | Amortized cost amount. | double |
6565
| aws.billing.AmortizedCost.unit | Amortized cost unit. | keyword |
6666
| aws.billing.BlendedCost.amount | Blended cost amount. | double |
@@ -80,9 +80,9 @@ An example event for `billing` looks as following:
8080
| aws.billing.group_definition.type | The string that represents the type of group. | keyword |
8181
| aws.billing.start_date | Start date for retrieving AWS costs. | keyword |
8282
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
83-
| aws.dimensions.* | Metric dimensions. | object |
83+
| aws.dimensions.\* | Metric dimensions. | object |
8484
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
85-
| aws.tags.* | Tag key value pairs from aws resources. | object |
85+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
8686
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
8787
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
8888
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/cloudwatch.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ An example event for `cloudwatch` looks as following:
112112
| Field | Description | Type |
113113
|---|---|---|
114114
| @timestamp | Event timestamp. | date |
115-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
115+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
116116
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
117-
| aws.dimensions.* | Metric dimensions. | object |
117+
| aws.dimensions.\* | Metric dimensions. | object |
118118
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
119-
| aws.tags.* | Tag key value pairs from aws resources. | object |
119+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
120120
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
121121
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
122122
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/dynamodb.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ An example event for `dynamodb` looks as following:
7171
| Field | Description | Type |
7272
|---|---|---|
7373
| @timestamp | Event timestamp. | date |
74-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
74+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
7575
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
76-
| aws.dimensions.* | Metric dimensions. | object |
76+
| aws.dimensions.\* | Metric dimensions. | object |
7777
| aws.dynamodb.metrics.AccountMaxReads.max | The maximum number of read capacity units that can be used by an account. This limit does not apply to on-demand tables or global secondary indexes. | long |
7878
| aws.dynamodb.metrics.AccountMaxTableLevelReads.max | The maximum number of read capacity units that can be used by a table or global secondary index of an account. For on-demand tables this limit caps the maximum read request units a table or a global secondary index can use. | long |
7979
| aws.dynamodb.metrics.AccountMaxTableLevelWrites.max | The maximum number of write capacity units that can be used by a table or global secondary index of an account. For on-demand tables this limit caps the maximum write request units a table or a global secondary index can use. | long |
@@ -102,7 +102,7 @@ An example event for `dynamodb` looks as following:
102102
| aws.dynamodb.metrics.TransactionConflict.sum | | long |
103103
| aws.dynamodb.metrics.WriteThrottleEvents.sum | Requests to DynamoDB that exceed the provisioned write capacity units for a table or a global secondary index. | long |
104104
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
105-
| aws.tags.* | Tag key value pairs from aws resources. | object |
105+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
106106
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
107107
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
108108
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/ebs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ An example event for `ebs` looks as following:
7878
| Field | Description | Type |
7979
|---|---|---|
8080
| @timestamp | Event timestamp. | date |
81-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
81+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
8282
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
83-
| aws.dimensions.* | Metric dimensions. | object |
83+
| aws.dimensions.\* | Metric dimensions. | object |
8484
| aws.dimensions.VolumeId | Amazon EBS volume ID | keyword |
8585
| aws.ebs.metrics.BurstBalance.avg | Used with General Purpose SSD (gp2), Throughput Optimized HDD (st1), and Cold HDD (sc1) volumes only. Provides information about the percentage of I/O credits (for gp2) or throughput credits (for st1 and sc1) remaining in the burst bucket. | double |
8686
| aws.ebs.metrics.VolumeConsumedReadWriteOps.avg | The total amount of read and write operations (normalized to 256K capacity units) consumed in a specified period of time. Used with Provisioned IOPS SSD volumes only. | double |
@@ -94,7 +94,7 @@ An example event for `ebs` looks as following:
9494
| aws.ebs.metrics.VolumeWriteBytes.avg | Average size of each write operation during the period, except on volumes attached to a Nitro-based instance, where the average represents the average over the specified period. | double |
9595
| aws.ebs.metrics.VolumeWriteOps.avg | The total number of write operations in a specified period of time. | double |
9696
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
97-
| aws.tags.* | Tag key value pairs from aws resources. | object |
97+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
9898
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
9999
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
100100
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/ec2.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ An example event for `ec2` looks as following:
170170
| Field | Description | Type |
171171
|---|---|---|
172172
| @timestamp | Event timestamp. | date |
173-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
173+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
174174
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
175-
| aws.dimensions.* | Metric dimensions. | object |
175+
| aws.dimensions.\* | Metric dimensions. | object |
176176
| aws.dimensions.AutoScalingGroupName | An Auto Scaling group is a collection of instances you define if you're using Auto Scaling. | keyword |
177177
| aws.dimensions.ImageId | This dimension filters the data you request for all instances running this Amazon EC2 Amazon Machine Image (AMI) | keyword |
178178
| aws.dimensions.InstanceId | Amazon EC2 instance ID | keyword |
@@ -212,7 +212,7 @@ An example event for `ec2` looks as following:
212212
| aws.ec2.status.check_failed_instance | Reports whether the instance has passed the instance status check in the last minute. | long |
213213
| aws.ec2.status.check_failed_system | Reports whether the instance has passed the system status check in the last minute. | long |
214214
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
215-
| aws.tags.* | Tag key value pairs from aws resources. | object |
215+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
216216
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
217217
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
218218
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/elb.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ An example event for `elb` looks as following:
181181
| Field | Description | Type |
182182
|---|---|---|
183183
| @timestamp | Event timestamp. | date |
184-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
184+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
185185
| aws.applicationelb.metrics.ActiveConnectionCount.sum | The total number of concurrent TCP connections active from clients to the load balancer and from the load balancer to targets. | long |
186186
| aws.applicationelb.metrics.ClientTLSNegotiationErrorCount.sum | The number of TLS connections initiated by the client that did not establish a session with the load balancer due to a TLS error. | long |
187187
| aws.applicationelb.metrics.ConsumedLCUs.avg | The number of load balancer capacity units (LCU) used by your load balancer. | double |
@@ -203,7 +203,7 @@ An example event for `elb` looks as following:
203203
| aws.applicationelb.metrics.RequestCount.sum | The number of requests processed over IPv4 and IPv6. | long |
204204
| aws.applicationelb.metrics.RuleEvaluations.sum | The number of rules processed by the load balancer given a request rate averaged over an hour. | long |
205205
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
206-
| aws.dimensions.* | Metric dimensions. | object |
206+
| aws.dimensions.\* | Metric dimensions. | object |
207207
| aws.dimensions.AvailabilityZone | Filters the metric data by the specified Availability Zone. | keyword |
208208
| aws.dimensions.LoadBalancer | Filters the metric data by load balancer. | keyword |
209209
| aws.dimensions.LoadBalancerName | Filters the metric data by the specified load balancer. | keyword |
@@ -242,7 +242,7 @@ An example event for `elb` looks as following:
242242
| aws.networkelb.metrics.TargetTLSNegotiationErrorCount.sum | The total number of TLS handshakes that failed during negotiation between a TLS listener and a target. | long |
243243
| aws.networkelb.metrics.UnHealthyHostCount.max | The number of targets that are considered unhealthy. | long |
244244
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
245-
| aws.tags.* | Tag key value pairs from aws resources. | object |
245+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
246246
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
247247
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
248248
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/lambda.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ An example event for `lambda` looks as following:
7070
| Field | Description | Type |
7171
|---|---|---|
7272
| @timestamp | Event timestamp. | date |
73-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
73+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
7474
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
75-
| aws.dimensions.* | Metric dimensions. | object |
75+
| aws.dimensions.\* | Metric dimensions. | object |
7676
| aws.dimensions.ExecutedVersion | Use the ExecutedVersion dimension to compare error rates for two versions of a function that are both targets of a weighted alias. | keyword |
7777
| aws.dimensions.FunctionName | Lambda function name. | keyword |
7878
| aws.dimensions.Resource | Resource name. | keyword |
@@ -90,7 +90,7 @@ An example event for `lambda` looks as following:
9090
| aws.lambda.metrics.Throttles.avg | The number of invocation requests that are throttled. | double |
9191
| aws.lambda.metrics.UnreservedConcurrentExecutions.avg | For an AWS Region, the number of events that are being processed by functions that don't have reserved concurrency. | double |
9292
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
93-
| aws.tags.* | Tag key value pairs from aws resources. | object |
93+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
9494
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
9595
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
9696
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/natgateway.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ An example event for `natgateway` looks as following:
9696
| Field | Description | Type |
9797
|---|---|---|
9898
| @timestamp | Event timestamp. | date |
99-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
99+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
100100
| aws.cloudwatch.namespace | The namespace specified when query cloudwatch api. | keyword |
101-
| aws.dimensions.* | Metric dimensions. | object |
101+
| aws.dimensions.\* | Metric dimensions. | object |
102102
| aws.dimensions.NatGatewayId | Filter the metric data by the NAT gateway ID. | keyword |
103103
| aws.natgateway.metrics.ActiveConnectionCount.max | The total number of concurrent active TCP connections through the NAT gateway. | long |
104104
| aws.natgateway.metrics.BytesInFromDestination.sum | The number of bytes received by the NAT gateway from the destination. | long |
@@ -115,7 +115,7 @@ An example event for `natgateway` looks as following:
115115
| aws.natgateway.metrics.PacketsOutToDestination.sum | The number of packets sent out through the NAT gateway to the destination. | long |
116116
| aws.natgateway.metrics.PacketsOutToSource.sum | The number of packets sent through the NAT gateway to the clients in your VPC. | long |
117117
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
118-
| aws.tags.* | Tag key value pairs from aws resources. | object |
118+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
119119
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
120120
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
121121
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

test/packages/aws/docs/rds.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ An example event for `rds` looks as following:
101101
| Field | Description | Type |
102102
|---|---|---|
103103
| @timestamp | Event timestamp. | date |
104-
| aws.*.metrics.*.* | Metrics that returned from Cloudwatch API query. | object |
105-
| aws.dimensions.* | Metric dimensions. | object |
104+
| aws.\*.metrics.\*.\* | Metrics that returned from Cloudwatch API query. | object |
105+
| aws.dimensions.\* | Metric dimensions. | object |
106106
| aws.dimensions.DBClusterIdentifier | This dimension filters the data that you request for a specific Amazon Aurora DB cluster. | keyword |
107107
| aws.dimensions.DBClusterIdentifier,Role | This dimension filters the data that you request for a specific Aurora DB cluster, aggregating the metric by instance role (WRITER/READER). | keyword |
108108
| aws.dimensions.DBInstanceIdentifier | This dimension filters the data that you request for a specific DB instance. | keyword |
@@ -185,7 +185,7 @@ An example event for `rds` looks as following:
185185
| aws.rds.volume_used.bytes | The amount of storage used by your Aurora DB instance, in bytes. | long |
186186
| aws.rds.write_io.ops_per_sec | The average number of disk write I/O operations per second. | float |
187187
| aws.s3.bucket.name | Name of a S3 bucket. | keyword |
188-
| aws.tags.* | Tag key value pairs from aws resources. | object |
188+
| aws.tags.\* | Tag key value pairs from aws resources. | object |
189189
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
190190
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
191191
| cloud.availability_zone | Availability zone in which this host is running. | keyword |

0 commit comments

Comments
 (0)