Commit c09a8b07 authored by Julius Volz's avatar Julius Volz

Merge pull request #99 from prometheus/fix-anchors

Sanitize and uniquify in-page anchors properly.
parents b4d20810 a9e17ba7
......@@ -63,7 +63,7 @@ during a scrape:
* the **count** of events that have been observed, exposed as `<basename>_count` (identical to `<basename>_bucket{le="+Inf"}` above)
Use the [`histogram_quantile()`
function](/docs/querying/functions/#histogram_quantile()) to calculate
function](/docs/querying/functions/#histogram_quantile) to calculate
quantiles from histograms or even aggregations of histograms. A
histogram is also suitable to calculate an [Apdex
score](http://en.wikipedia.org/wiki/Apdex). See [histograms and
......
......@@ -74,7 +74,7 @@ geared towards slightly different use cases.
### Scope
The same scope differences as in the case of
[Graphite](/docs/introduction/comparison/#prometheus-vs.-graphite) apply here.
[Graphite](/docs/introduction/comparison/#prometheus-vs-graphite) apply here.
### Data model / storage
......@@ -139,7 +139,7 @@ node outages due to data replication.
### Scope
The same scope differences as in the case of
[Graphite](/docs/introduction/comparison/#prometheus-vs.-graphite) apply here.
[Graphite](/docs/introduction/comparison/#prometheus-vs-graphite) apply here.
### Data model
......
......@@ -91,7 +91,7 @@ calculate streaming φ-quantiles on the client side and expose them directly,
while histograms expose bucketed observation counts and the calculation of
quantiles from the buckets of a histogram happens on the server side using the
[`histogram_quantile()`
function](/docs/querying/functions/#histogram_quantile()).
function](/docs/querying/functions/#histogram_quantile).
The two approaches have a number of different implications:
......@@ -102,8 +102,8 @@ The two approaches have a number of different implications:
| Server performance | The server has to calculate quantiles. You can use [recording rules](/docs/querying/rules/#recording-rules) should the ad-hoc calculation take too long (e.g. in a large dashboard). | Low server-side cost.
| Number of time series (in addition to the `_sum` and `_count` series) | One time series per configured bucket. | One time series per configured quantile.
| Quantile error (see below for details) | Error is limited in the dimension of observed values by the width of the relevant bucket. | Error is limited in the dimension of φ by a configurable value.
| Specification of φ-quantile and sliding time-window | Ad-hoc with [Prometheus expressions](/docs/querying/functions/#histogram_quantile()). | Preconfigured by the client.
| Aggregation | Ad-hoc with [Prometheus expressions](/docs/querying/functions/#histogram_quantile()). | In general [not aggregatable](http://latencytipoftheday.blogspot.de/2014/06/latencytipoftheday-you-cant-average.html).
| Specification of φ-quantile and sliding time-window | Ad-hoc with [Prometheus expressions](/docs/querying/functions/#histogram_quantile). | Preconfigured by the client.
| Aggregation | Ad-hoc with [Prometheus expressions](/docs/querying/functions/#histogram_quantile). | In general [not aggregatable](http://latencytipoftheday.blogspot.de/2014/06/latencytipoftheday-you-cant-average.html).
Note the importance of the last item in the table. Let us return to
the SLA of serving 95% of requests within 300ms. This time, you do not
......@@ -124,7 +124,7 @@ quantiles yields statistically nonsensical values.
Using histograms, the aggregation is perfectly possible with the
[`histogram_quantile()`
function](/docs/querying/functions/#histogram_quantile()).
function](/docs/querying/functions/#histogram_quantile).
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) // GOOD.
......
......@@ -29,7 +29,7 @@ The example consoles have 5 parts:
1. A table on the right
The navigation bar is for links to other systems, such as other Prometheis
<sup>[1](/docs/introduction/faq/#what-is-the-plural-of-prometheus?)</sup>,
<sup>[1](/docs/introduction/faq/#what-is-the-plural-of-prometheus)</sup>,
documentation, and whatever else makes sense to you. The menu is for navigation
inside the same Prometheus server, which is very useful to be able to quickly
open a console in another tab to correlate information. Both are configured in
......
......@@ -7,6 +7,7 @@ class AddAnchorsFilter < ::Nanoc::Filter
identifier :add_anchors
def run(content, params={})
anchors = {}
# `#dup` is necessary because `.fragment` modifies the incoming string. Ew!
# See https://github.com/sparklemotion/nokogiri/issues/1077
doc = Nokogiri::HTML::DocumentFragment.parse(content.dup)
......@@ -15,7 +16,22 @@ class AddAnchorsFilter < ::Nanoc::Filter
node = Nokogiri::XML::Node.new('a', doc).tap do |a|
a.content = ''
a['class'] = 'header-anchor'
a['href'] = '#' + h_node['id']
# Replace sequences of non-word characters with single dashes. Remove
# extra dashes at the beginning or end.
anchor = h_node['id'].gsub(/\W+/, '-').gsub(/^-+|-+$/, '')
i = 0
unique_anchor = anchor
while anchors[unique_anchor] do
unique_anchor = "#{anchor}-#{i}"
i += 1
end
anchor = unique_anchor
anchors[anchor] = true
a['href'] = '#' + anchor
a['name'] = anchor
end
h_node.add_child(node)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment