{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/docs/pulls/comments/25570051","id":25570051,"diff_hunk":"@@ -50,31 +58,101 @@ either `0` (`false`) or `1` (`true`), depending on the comparison result.\n value of every data sample in the vector, and vector elements between which the\n comparison result is `false` get dropped from the result vector.\n \n-**Between two instant vectors**, these operators behave as a filter: They apply\n-to vector elements that have identical sets of labels between the two vectors.\n-Vector elements for which the expression evaluates to `false` or which don't\n-find an exact label match on the other side of the expression get dropped from\n-the result, while the others get carried over into a result vector with their\n-original (left-hand-side) metric names and data values.\n+**Between two instant vectors**, these operators behave as a filter, applied to\n+matching entries. Vector elements for which the expression is not true or\n+which do not find a match on the other side of the expression get dropped from the\n+result, while the others are propagated into a result vector with their original\n+(left-hand-side) metric names and label values.\n \n-# Logical/set binary operators\n+### Logical/set binary operators\n \n These logical/set binary operators are only defined between instant vectors:\n \n * `and` (intersection)\n-* `or` (union) (**not yet implemented!**)\n+* `or` (union)\n \n `vector1 and vector2` results in a vector consisting of the elements of\n `vector1` for which there are elements in `vector2` with exactly matching\n-labelsets. Other elements are dropped. The metric name and values are carried\n+label sets. Other elements are dropped. The metric name and values are carried\n over from the left-hand-side vector.\n \n `vector1 or vector2` results in a vector that contains all original elements\n-(labelsets + values) of `vector1` and additionally all elements of `vector2`,\n-which don't have matching labelsets in `vector1`. The metric name is carried\n-over from the left-hand-side vector in both cases.\n+(label sets + values) of `vector1` and additionally all elements of `vector2`,\n+which do not have matching label sets in `vector1`.\n+\n+## Vector matching\n+\n+Operations between vectors attempt to find a matching element in the right-hand-side\n+vector for each entry in the left-hand-side. There are two basic types of\n+matching behaviour:\n+\n+**One-to-one** finds a unique pair of entries from each side of the operation.\n+In the default case, that is an operation following the format `vector1 <operator> vector2`.\n+Two entries match if they have the exact same set of labels and corresponding values.\n+The `on` keyword allows reducing the set of considered labels to a provided list:\n+\n+    <vector expr> <bin-op> on(<label list>) <vector expr>\n+\n+Example input:\n+\n+    method:http_errors:rate5m{method=\"get\", code=\"500\"}  24\n+    method:http_errors:rate5m{method=\"get\", code=\"404\"}  30\n+    method:http_errors:rate5m{method=\"put\", code=\"500\"}  3\n+    method:http_errors:rate5m{method=\"post\", code=\"500\"} 6\n+    method:http_errors:rate5m{method=\"post\", code=\"404\"} 21\n+\n+    method:http_requests:rate5m{method=\"get\"}  600\n+    method:http_requests:rate5m{method=\"del\"}  34\n+    method:http_requests:rate5m{method=\"post\"} 120\n+\n+Example query:\n+\n+    method:http_errors:rate5m{code=\"500\"} / on(method) method:http_requests:rate5m\n+\n+This returns a result vector that tells us what fraction of requests had an HTTP\n+status code of 500 for each method over the last 5 minutes. Without `on(method)` there\n+would have been no match as the metrics do not share the same set of labels.\n+The entries with methods `put` and `del` have no match and will not show up in the result:\n+\n+\t{method=\"get\"}  0.04 \t\t\t//  24 / 600\n+\t{method=\"post\"} 0.1\t\t\t\t//  12 / 120\n+\n+**Many-to-one** and **one-to-many** matchings refer to the case that each vector entry on","path":"content/docs/querying/operators.md","position":124,"original_position":124,"commit_id":"1853a23214d9dd4992ed1f5a02d45fc75f1a8727","original_commit_id":"1853a23214d9dd4992ed1f5a02d45fc75f1a8727","user":{"login":"juliusv","id":538008,"avatar_url":"https://avatars.githubusercontent.com/u/538008?v=3","gravatar_id":"","url":"https://api.github.com/users/juliusv","html_url":"https://github.com/juliusv","followers_url":"https://api.github.com/users/juliusv/followers","following_url":"https://api.github.com/users/juliusv/following{/other_user}","gists_url":"https://api.github.com/users/juliusv/gists{/gist_id}","starred_url":"https://api.github.com/users/juliusv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliusv/subscriptions","organizations_url":"https://api.github.com/users/juliusv/orgs","repos_url":"https://api.github.com/users/juliusv/repos","events_url":"https://api.github.com/users/juliusv/events{/privacy}","received_events_url":"https://api.github.com/users/juliusv/received_events","type":"User","site_admin":false},"body":"s/case that/case where/?","created_at":"2015-03-01T19:05:07Z","updated_at":"2015-03-01T19:05:07Z","html_url":"https://github.com/prometheus/docs/pull/48#discussion_r25570051","pull_request_url":"https://api.github.com/repos/prometheus/docs/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/prometheus/docs/pulls/comments/25570051"},"html":{"href":"https://github.com/prometheus/docs/pull/48#discussion_r25570051"},"pull_request":{"href":"https://api.github.com/repos/prometheus/docs/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/docs/pulls/48","id":30161832,"html_url":"https://github.com/prometheus/docs/pull/48","diff_url":"https://github.com/prometheus/docs/pull/48.diff","patch_url":"https://github.com/prometheus/docs/pull/48.patch","issue_url":"https://api.github.com/repos/prometheus/docs/issues/48","number":48,"state":"open","locked":false,"title":"Documentation for vector matching added.","user":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-27T12:16:04Z","updated_at":"2015-03-01T19:05:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8008a923c090a123b8dedd6719e257de9988c616","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/docs/pulls/48/commits","review_comments_url":"https://api.github.com/repos/prometheus/docs/pulls/48/comments","review_comment_url":"https://api.github.com/repos/prometheus/docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/docs/issues/48/comments","statuses_url":"https://api.github.com/repos/prometheus/docs/statuses/1853a23214d9dd4992ed1f5a02d45fc75f1a8727","head":{"label":"fabxc:fabxc/vector_matching","ref":"fabxc/vector_matching","sha":"1853a23214d9dd4992ed1f5a02d45fc75f1a8727","user":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"repo":{"id":31416543,"name":"docs","full_name":"fabxc/docs","owner":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabxc/docs","description":"Prometheus documentation: content and static site generator","fork":true,"url":"https://api.github.com/repos/fabxc/docs","forks_url":"https://api.github.com/repos/fabxc/docs/forks","keys_url":"https://api.github.com/repos/fabxc/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabxc/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabxc/docs/teams","hooks_url":"https://api.github.com/repos/fabxc/docs/hooks","issue_events_url":"https://api.github.com/repos/fabxc/docs/issues/events{/number}","events_url":"https://api.github.com/repos/fabxc/docs/events","assignees_url":"https://api.github.com/repos/fabxc/docs/assignees{/user}","branches_url":"https://api.github.com/repos/fabxc/docs/branches{/branch}","tags_url":"https://api.github.com/repos/fabxc/docs/tags","blobs_url":"https://api.github.com/repos/fabxc/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabxc/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabxc/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabxc/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabxc/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/fabxc/docs/languages","stargazers_url":"https://api.github.com/repos/fabxc/docs/stargazers","contributors_url":"https://api.github.com/repos/fabxc/docs/contributors","subscribers_url":"https://api.github.com/repos/fabxc/docs/subscribers","subscription_url":"https://api.github.com/repos/fabxc/docs/subscription","commits_url":"https://api.github.com/repos/fabxc/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabxc/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabxc/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabxc/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabxc/docs/contents/{+path}","compare_url":"https://api.github.com/repos/fabxc/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabxc/docs/merges","archive_url":"https://api.github.com/repos/fabxc/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabxc/docs/downloads","issues_url":"https://api.github.com/repos/fabxc/docs/issues{/number}","pulls_url":"https://api.github.com/repos/fabxc/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/fabxc/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/fabxc/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabxc/docs/labels{/name}","releases_url":"https://api.github.com/repos/fabxc/docs/releases{/id}","created_at":"2015-02-27T11:32:49Z","updated_at":"2015-02-27T11:32:49Z","pushed_at":"2015-03-01T14:22:39Z","git_url":"git://github.com/fabxc/docs.git","ssh_url":"git@github.com:fabxc/docs.git","clone_url":"https://github.com/fabxc/docs.git","svn_url":"https://github.com/fabxc/docs","homepage":"http://prometheus.io","size":2617,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"a33f2ca04ff592805954bbcc4c83ce0317f7be46","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":28233924,"name":"docs","full_name":"prometheus/docs","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/docs","description":"Prometheus documentation: content and static site generator","fork":false,"url":"https://api.github.com/repos/prometheus/docs","forks_url":"https://api.github.com/repos/prometheus/docs/forks","keys_url":"https://api.github.com/repos/prometheus/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/docs/teams","hooks_url":"https://api.github.com/repos/prometheus/docs/hooks","issue_events_url":"https://api.github.com/repos/prometheus/docs/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/docs/events","assignees_url":"https://api.github.com/repos/prometheus/docs/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/docs/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/docs/tags","blobs_url":"https://api.github.com/repos/prometheus/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/docs/languages","stargazers_url":"https://api.github.com/repos/prometheus/docs/stargazers","contributors_url":"https://api.github.com/repos/prometheus/docs/contributors","subscribers_url":"https://api.github.com/repos/prometheus/docs/subscribers","subscription_url":"https://api.github.com/repos/prometheus/docs/subscription","commits_url":"https://api.github.com/repos/prometheus/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/docs/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/docs/merges","archive_url":"https://api.github.com/repos/prometheus/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/docs/downloads","issues_url":"https://api.github.com/repos/prometheus/docs/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/docs/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/docs/releases{/id}","created_at":"2014-12-19T15:06:35Z","updated_at":"2015-02-28T12:57:55Z","pushed_at":"2015-02-28T12:57:55Z","git_url":"git://github.com/prometheus/docs.git","ssh_url":"git@github.com:prometheus/docs.git","clone_url":"https://github.com/prometheus/docs.git","svn_url":"https://github.com/prometheus/docs","homepage":"http://prometheus.io","size":2617,"stargazers_count":4,"watchers_count":4,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/docs/pulls/48"},"html":{"href":"https://github.com/prometheus/docs/pull/48"},"issue":{"href":"https://api.github.com/repos/prometheus/docs/issues/48"},"comments":{"href":"https://api.github.com/repos/prometheus/docs/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/docs/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/docs/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/docs/statuses/1853a23214d9dd4992ed1f5a02d45fc75f1a8727"}}}}