<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.foji.io/index.php?action=history&amp;feed=atom&amp;title=Querying_FojiSoft_Metrics_-_Examples</id>
	<title>Querying FojiSoft Metrics - Examples - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://docs.foji.io/index.php?action=history&amp;feed=atom&amp;title=Querying_FojiSoft_Metrics_-_Examples"/>
	<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;action=history"/>
	<updated>2026-06-19T10:25:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=2604&amp;oldid=prev</id>
		<title>Chris.Hansen at 17:59, 21 February 2025</title>
		<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=2604&amp;oldid=prev"/>
		<updated>2025-02-21T17:59:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:59, 21 February 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l52&quot;&gt;Line 52:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 52:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;lt;code&amp;gt;count by (app) (instance_cpu_time_ns)&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;lt;code&amp;gt;count by (app) (instance_cpu_time_ns)&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Visualize]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Visualize]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Querying Metrics]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-1265:rev-2604 --&gt;
&lt;/table&gt;</summary>
		<author><name>Chris.Hansen</name></author>
	</entry>
	<entry>
		<id>https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=1265&amp;oldid=prev</id>
		<title>Mitchell.Hirsche at 23:49, 6 March 2024</title>
		<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=1265&amp;oldid=prev"/>
		<updated>2024-03-06T23:49:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:49, 6 March 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l51&quot;&gt;Line 51:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Assuming this metric contains one time series per running instance, you could count the number of running instances per application like this:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Assuming this metric contains one time series per running instance, you could count the number of running instances per application like this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;lt;code&amp;gt;count by (app) (instance_cpu_time_ns)&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;lt;code&amp;gt;count by (app) (instance_cpu_time_ns)&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Visualize]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-1252:rev-1265 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mitchell.Hirsche</name></author>
	</entry>
	<entry>
		<id>https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=1252&amp;oldid=prev</id>
		<title>Mitchell.Hirsche: Examples of queries in FojiSoft using PromQL.</title>
		<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Querying_FojiSoft_Metrics_-_Examples&amp;diff=1252&amp;oldid=prev"/>
		<updated>2024-03-06T23:44:26Z</updated>

		<summary type="html">&lt;p&gt;Examples of queries in FojiSoft using PromQL.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
= QUERY EXAMPLES =&lt;br /&gt;
&lt;br /&gt;
* Simple time series selection&lt;br /&gt;
* Subquery&lt;br /&gt;
* Using functions, operators, etc.&lt;br /&gt;
&lt;br /&gt;
== Simple time series selection ==&lt;br /&gt;
Return all time series with the metric &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt;&lt;br /&gt;
Return all time series with the metric &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt; and the given &amp;lt;code&amp;gt;job&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;handler&amp;lt;/code&amp;gt; labels:&lt;br /&gt;
 &amp;lt;code&amp;gt;http_requests_total{job=&amp;quot;apiserver&amp;quot;, handler=&amp;quot;/api/comments&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
Return a whole range of time (in this case 5 minutes up to the query time) for the same vector, making it a range vector:&lt;br /&gt;
 &amp;lt;code&amp;gt;http_requests_total{job=&amp;quot;apiserver&amp;quot;, handler=&amp;quot;/api/comments&amp;quot;}[5m]&amp;lt;/code&amp;gt;&lt;br /&gt;
Note that an expression resulting in a range vector cannot be graphed directly, but viewed in the tabular (&amp;quot;Console&amp;quot;) view of the expression browser.&lt;br /&gt;
&lt;br /&gt;
Using regular expressions, you could select time series only for jobs whose name match a certain pattern, in this case, all jobs that end with &amp;lt;code&amp;gt;server&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;code&amp;gt;http_requests_total{job=~&amp;quot;.*server&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
All regular expressions in FojiSoft with PromQL use RE2 syntax.&lt;br /&gt;
&lt;br /&gt;
To select all HTTP status codes except 4xx ones, you could run:&lt;br /&gt;
 &amp;lt;code&amp;gt;http_requests_total{status!~&amp;quot;4..&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subquery ==&lt;br /&gt;
Return the 5-minute rate of the &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt; metric for the past 30 minutes, with a resolution of 1 minute.&lt;br /&gt;
 &amp;lt;code&amp;gt;rate(http_requests_total[5m])[30m:1m]&amp;lt;/code&amp;gt;&lt;br /&gt;
This is an example of a nested subquery. The subquery for the &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt; function uses the default resolution. Note that using subqueries unnecessarily is unwise.&lt;br /&gt;
 &amp;lt;code&amp;gt;max_over_time(deriv(rate(distance_covered_total[5s])[30s:5s])[10m:])&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using functions, operators, etc. ==&lt;br /&gt;
Return the per-second rate for all time series with the &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt; metric name, as measured over the last 5 minutes:&lt;br /&gt;
 &amp;lt;code&amp;gt;rate(http_requests_total[5m])&amp;lt;/code&amp;gt;&lt;br /&gt;
Assuming that the &amp;lt;code&amp;gt;http_requests_total&amp;lt;/code&amp;gt; time series all have the labels &amp;lt;code&amp;gt;job&amp;lt;/code&amp;gt; (fanout by job name) and &amp;lt;code&amp;gt;instance&amp;lt;/code&amp;gt; (fanout by instance of the job), we might want to sum over the rate of all instances, so we get fewer output time series, but still preserve the &amp;lt;code&amp;gt;job&amp;lt;/code&amp;gt; dimension:&lt;br /&gt;
 &amp;lt;code&amp;gt;sum by (job) (&lt;br /&gt;
   rate(http_requests_total[5m])&lt;br /&gt;
 )&amp;lt;/code&amp;gt;&lt;br /&gt;
If we have two different metrics with the same dimensional labels, we can apply binary operators to them and elements on both sides with the same label set will get matched and propagated to the output. For example, this expression returns the unused memory in MiB for every instance (on a fictional cluster scheduler exposing these metrics about the instances it runs):&lt;br /&gt;
 &amp;lt;code&amp;gt;(instance_memory_limit_bytes - instance_memory_usage_bytes) / 1024 / 1024&amp;lt;/code&amp;gt;&lt;br /&gt;
The same expression, but summed by application, could be written like this:&lt;br /&gt;
 &amp;lt;code&amp;gt;sum by (app, proc) (&lt;br /&gt;
   instance_memory_limit_bytes - instance_memory_usage_bytes&lt;br /&gt;
 ) / 1024 / 1024&amp;lt;/code&amp;gt;&lt;br /&gt;
If the same fictional cluster scheduler exposed CPU usage metrics like the following for every instance:&lt;br /&gt;
 &amp;lt;code&amp;gt;instance_cpu_time_ns{app=&amp;quot;lion&amp;quot;, proc=&amp;quot;web&amp;quot;, rev=&amp;quot;34d0f99&amp;quot;, env=&amp;quot;prod&amp;quot;, job=&amp;quot;cluster-manager&amp;quot;}&lt;br /&gt;
 instance_cpu_time_ns{app=&amp;quot;elephant&amp;quot;, proc=&amp;quot;worker&amp;quot;, rev=&amp;quot;34d0f99&amp;quot;, env=&amp;quot;prod&amp;quot;, job=&amp;quot;cluster-manager&amp;quot;}&lt;br /&gt;
 instance_cpu_time_ns{app=&amp;quot;turtle&amp;quot;, proc=&amp;quot;api&amp;quot;, rev=&amp;quot;4d3a513&amp;quot;, env=&amp;quot;prod&amp;quot;, job=&amp;quot;cluster-manager&amp;quot;}&lt;br /&gt;
 instance_cpu_time_ns{app=&amp;quot;fox&amp;quot;, proc=&amp;quot;widget&amp;quot;, rev=&amp;quot;4d3a513&amp;quot;, env=&amp;quot;prod&amp;quot;, job=&amp;quot;cluster-manager&amp;quot;}&lt;br /&gt;
 ...&amp;lt;/code&amp;gt;&lt;br /&gt;
...we could get the top 3 CPU users grouped by application (&amp;lt;code&amp;gt;app&amp;lt;/code&amp;gt;) and process type (&amp;lt;code&amp;gt;proc&amp;lt;/code&amp;gt;) like this:&lt;br /&gt;
 &amp;lt;code&amp;gt;topk(3, sum by (app, proc) (rate(instance_cpu_time_ns[5m])))&amp;lt;/code&amp;gt;&lt;br /&gt;
Assuming this metric contains one time series per running instance, you could count the number of running instances per application like this:&lt;br /&gt;
 &amp;lt;code&amp;gt;count by (app) (instance_cpu_time_ns)&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mitchell.Hirsche</name></author>
	</entry>
</feed>