├── .github └── workflows │ └── ci.yml ├── LICENSE ├── Makefile ├── README.md ├── promformat ├── __init__.py ├── __main__.py ├── ast_nodes.py ├── buffer.py ├── error.py ├── formatter.py └── parser │ ├── PromQLLexer.interp │ ├── PromQLLexer.py │ ├── PromQLLexer.tokens │ ├── PromQLParser.interp │ ├── PromQLParser.py │ ├── PromQLParser.tokens │ ├── PromQLParserListener.py │ ├── PromQLParserVisitor.py │ └── __init__.py ├── setup.py └── tests ├── __init__.py ├── resources ├── __init__.py ├── formatted │ ├── 00992daead1333589551e2c702cb583d │ ├── 00ff2c1629e21834cf03a43ca0266763 │ ├── 01c5ed5def7d1bc5d1db969aaab1949a │ ├── 0241aea91b6a92c6343e7f0a1fed5610 │ ├── 02db4cafaf59e43715109eca280bbf18 │ ├── 038b224f783314c387cbfcd31e21acb3 │ ├── 043c7280da7d6e4a95d14d828eeb92b2 │ ├── 047aab58010d14e9b4e08eda3aa02862 │ ├── 0484b128ae0ef3bfe4bf4fe400c369b3 │ ├── 0496da0631b0e8e4c8200a1f582b90c5 │ ├── 04bb59d9823b25195fb41b45a7e24d1b │ ├── 053b7e540b1890cef3ec7d55ba8f727d │ ├── 06621b9b60933e0fc906a897b796359e │ ├── 06750f0ccb028acfb7d300abdffbd16b │ ├── 0683afa7bdfef12041d0bd1e432dca12 │ ├── 06f166ed3b43fff5a0e9193347ebe5ad │ ├── 074327596df2f7e998c1f1daf49fa955 │ ├── 078f7ce131e780d087612f60db549212 │ ├── 08580b2bc21e75bbcb70ff77e65a0ddd │ ├── 0869b90054562b7a571a932f3ad665fd │ ├── 08a226e383c2250387a370931cfbb13d │ ├── 08dfe49ee5fcbf510731e6cf2c5bba7d │ ├── 09f49b27d067909a24b45ee91a0a7418 │ ├── 0a2f212f22cc3211cd3c927521b47bc6 │ ├── 0aaba81532e0cda8a7ec0f901e0389c1 │ ├── 0b796afc52a94801512bc493283f2ba7 │ ├── 0baea55faa2cdb786e5c5b24b3a7a8ca │ ├── 0ca9626022ca1ed2f098301d7a64ed83 │ ├── 0ca969420398567379630625489ac0cc │ ├── 0d0007fe01eb88384d0ae329e16fcf39 │ ├── 0d78ef575b9937a4222b9887e265d4df │ ├── 0de4ca80a6d09176d3972dbae80a5816 │ ├── 0e2326fffa446af244a937f9630e562d │ ├── 0ef8cdb32570e82551971243ecbc308c │ ├── 10039edb33bdf3e22b4063402eb743be │ ├── 100459494810732b1b97ab5446a1c307 │ ├── 10fb62c9c8fc7eb829483b4cd36882c6 │ ├── 127c754b60ab5c88fadea4890488814a │ ├── 12c2ffb1a0fb3d5164a8fbbf0293ef02 │ ├── 14e4e8c8ff63699650da3364eaf94355 │ ├── 14e6e062b5aa8312dfa1fa51b08c6997 │ ├── 15d6c11dbb647627dd3b15601e127802 │ ├── 15eced1d51bd4c6adc01e8225e0b7cdb │ ├── 1663f41ff1bf15a2bf431c74799882dc │ ├── 16a7a77d7e5998d3eda1e902811a1f6a │ ├── 179b99cfb83afb3a9a7cf8680c1d19e1 │ ├── 18439ae9c6aedc7e3ea735ef0b1a7aba │ ├── 187b5984888e0d714d181529c305a4cf │ ├── 1aae9d86ccd81a4edd9741f62971828b │ ├── 1bad85060ec7f660717c2ca3d2569aed │ ├── 1ce7859219038f31542b05549a879d8e │ ├── 1d1d808b2333c06fddb3609b33f4b266 │ ├── 1d31cc16283784f40ac854370c31eae7 │ ├── 1d749538e497451f2b338809dd2d574b │ ├── 1dd6c030ed37a8409ec32df3d96d1c90 │ ├── 2175364057816e0787f2e2ab35d9e147 │ ├── 218b6e28bd5fe73566742a49b5a41776 │ ├── 219dae2934e4bbce22464e86aac12401 │ ├── 22149109d5523dcc21de9c670395a05d │ ├── 22580c3a43d956b13b243e7a4e3d6f7b │ ├── 22c8b9cccc9de20f97b390ded1f4e11b │ ├── 22fa225f86a7c5a480c8539edd73ecf1 │ ├── 23543ac00f69c154f8bcde48d32551ce │ ├── 238f5bb318b38e0ef92b93900b83379b │ ├── 2557f48dc46a64040fe7b22c53588613 │ ├── 2597f94df7ef269a4f841d56044d46f0 │ ├── 2673d4ef2b7ace382a333441e7c868b7 │ ├── 278e3336392144a07e3dfe302949d49d │ ├── 280d2da9d088279fc39900a1e6c0cd61 │ ├── 29daba2cf53bb7f2c917326a78b6c385 │ ├── 2a059cdc137a9fef270946ae3e3b8fac │ ├── 2a0afbbfbe27a4a4174f5e0024bf3bfb │ ├── 2a18b091f9b2e8d2cc59febea2af8c05 │ ├── 2a79df2a227783b07c15acc3be464360 │ ├── 2a7e5f9a95cf3c4b7748085c48a031d6 │ ├── 2bb024abfabe4fce5cb1425e89f9ce74 │ ├── 2c13a6b8c7d3a807a646b4cd2c8cfe12 │ ├── 2e2aed13efb482e0f4b71a027c576c4d │ ├── 2f2bdfbd374938d0da09a027a3bf6a53 │ ├── 3085f81804488dfac43ea0ed9e894c8a │ ├── 309faac35b97d43054b7f50dc0beaf7e │ ├── 30c250d5b994b8bd98bfc53ebd13862a │ ├── 30dfe4d9bd31585e824fc4e5319be271 │ ├── 313e3c3ea988d078348c59099eba4824 │ ├── 323efa33184302d23fef32942db94d9d │ ├── 3406caff3871270a823940892a6ce10e │ ├── 35dd9d9b897addb6661ef9c4a5d92a3b │ ├── 372e3e559cd3e932f550c6ac7f518682 │ ├── 376b5fcdfe13e2bed3fce8638e760e56 │ ├── 3939e3dfd95f7c838f6088be5fb2e117 │ ├── 39530e6a688b2a15c72fd94c5a1763d4 │ ├── 39741c5b0dc404a8687390e0491cc77a │ ├── 39ad5afa022bc47841d922ee0eea66f6 │ ├── 3a3a580bb207850421262e8ff199d78e │ ├── 3ae4d713074b2b5218a177a46786fae3 │ ├── 3b8074526509927589c1e30f3d12b214 │ ├── 3cd4bd937a5b13850c9455ce204f380b │ ├── 3d800d8a44b35e5879d0b81341f84048 │ ├── 40c101d2dcbf5587289fc601b67a22f6 │ ├── 4147c794c7dc4f994cf3fe020d620203 │ ├── 41f1469d76f9549c73ae1d3cf3a20d3d │ ├── 42c4a1e9f0ad4293a2823f11648cea91 │ ├── 44c32b3bb7d6b0f5a2cd9fa4842b316f │ ├── 45363f5e542b13f0f05206d0a4fc1fa5 │ ├── 45c2f5d1e79d46705138e208e1fe09f7 │ ├── 461b7d0cc835124fac20df180d819439 │ ├── 467dd2566644e26d502c800eaaf817bf │ ├── 4699ee30956330789bb287444c305e19 │ ├── 46aa895948f144971fd2f880dca4dbb0 │ ├── 4710aad682f74be9ef019722131edd8b │ ├── 472a4d6ef6fd9e207fbbfab257d31053 │ ├── 476d610a875d6efa428ba970f2cb5fc5 │ ├── 47b8fd31faa13be41b34b1c472f86006 │ ├── 47bc1470637a125b9abed39055bc8c35 │ ├── 486d59df21d8804cfef4db712d643128 │ ├── 48c218a18c0faf76b03d14863bdbbcc0 │ ├── 49cd02974e92c1015f42be22770bcf26 │ ├── 4ac132bb2d4ee8346ac98795ca684f24 │ ├── 4b11da7b96971dab7d6904081699b398 │ ├── 4ba8bc45a03e88a0490ae667fbf9ade6 │ ├── 4c0581efcfc3cfb0eef4f2aa7fe94cdb │ ├── 4c58b8111c3317ee7721887159296229 │ ├── 4d61c0c1bcdde463a8c413f7fdfa4433 │ ├── 4ed30eb3a4380c1aaed21a70d6f4fb63 │ ├── 4eeebd21cca3228b59ab8f40a2d7fc04 │ ├── 4f900c97f46487e827bcecb013974b01 │ ├── 512dadfbc73ce8561229a76a74fd1bf7 │ ├── 51b5bfe040fbcddc2697723e6c4572e4 │ ├── 51ee6967c680682380d9c8e5976b37f7 │ ├── 52a0461e2309172d5e91d41e7b88afb4 │ ├── 5351f61102d3fc070d3efaa673c2aa28 │ ├── 5396757274965e70435a14433b1360f9 │ ├── 541c2e09d6596bfb9576e24794990d19 │ ├── 5463ace5e4e049fd967210fd2ee47280 │ ├── 553e4d9667175e13f01cac13aca530de │ ├── 558b2ae0b2595dc81eaec7897bcfd3ab │ ├── 5599c5137f950002466f7d48803397e7 │ ├── 56064474cd38b8d920ff864761609051 │ ├── 562659c5dcb9b0b2136d9c41557e1424 │ ├── 56470ecd5c4d46fcd6e2cb1fab7d8d10 │ ├── 567441a2715bee0760f7f45be9f37e1c │ ├── 578255c148e46045351b2bc96cc1c968 │ ├── 581885bd4824b2b53a9ea0874f4f0197 │ ├── 585d1aa1d9797513feec80ab3211671c │ ├── 5ba8fe4b0876b269ab5f3e544684a8bd │ ├── 5c2e83d4e39b191150e04d4bb7d35f0c │ ├── 5c71e8e5ea96a9f45ebc3f474a2a2cf3 │ ├── 5cf7206d78ad1318476419622e2059e2 │ ├── 5da6a38c886aa8b734349aea03267adc │ ├── 5dc5aa0b4aa448f2a6645c75e34698ba │ ├── 5e19fd0fdd2e74f2f7a32349159fd128 │ ├── 5ebe07d7a073983e7862a5fc6c0743b9 │ ├── 5ee1becba2ccca75b6fd34f26d93b959 │ ├── 5f58e450a64c5f61ff61615bb2c403fb │ ├── 5f5e9e08b25672f614ea90660623d65b │ ├── 5fc3b72e21a36ace4758bbb5ef4dc65b │ ├── 601c919905fec9701fbfa41cca3647c9 │ ├── 602bee0be8a56902b7fd87950f698897 │ ├── 626d523a34ed3c1656c0698100cf2473 │ ├── 628e7d78033ced13b5b101b6c664f5b2 │ ├── 62c3da4578f624ed2ca800a87a6018df │ ├── 6346e927541043839869beb1474911cd │ ├── 63a74fd665adab43030e192fe52d2929 │ ├── 63e5b2b69a0b55eb797a33142ca51ac1 │ ├── 6535aa472094e27e4240bf49da2840dc │ ├── 673a4d7c2ba602c206ad0eec7df5d4ee │ ├── 686a3acb521e1ac08f34132f6b5b38f7 │ ├── 68733903b224f31b1d12971670b37f12 │ ├── 688c79ecded72c6e7c58b6d4f1f51d86 │ ├── 6956e54febb750f78bd2d697db1c31a5 │ ├── 696658abb97057f51361a2d9d94bb8db │ ├── 69b85345930e4e1ee27cf9fd96793dab │ ├── 69c203c12117f92a4b81ecb37aaf2a66 │ ├── 69dcf611b26f4d8a3ae17dafeccf9dc2 │ ├── 6aa868b60cbaf4ce158266e556fbe15d │ ├── 6ae4af3df41f87470e3c84f2ded415d8 │ ├── 6b51b71f728da4866dd295b3e97b2891 │ ├── 6c21a01cdba0a69d58710c7269cb62ea │ ├── 6c6283280102b331df52dab9f014af3e │ ├── 6d32823628e23c732c297fc7b92553ce │ ├── 6ece92e701544479fe0e7cef82405e84 │ ├── 6f2a62df4b51bdbc8da4957764ad8707 │ ├── 6f9acfa0498e6b25170500ecb935f226 │ ├── 7006fa216f3c8156f7a003dbc077c116 │ ├── 70ceec0763cbbd9d05addad72bbb1e8a │ ├── 71734b49170e5d199b5082f64a26622a │ ├── 71b3d2d10c7585936d658d167be3f214 │ ├── 73dc546ba11f418b933e74343498f1c9 │ ├── 74681db3101935154d03e554af87a332 │ ├── 754b9b5ebf9f13ac0b1dc209a430762e │ ├── 7556330e9311efd33244e6040aec0319 │ ├── 75b459eebb4e022cb8526fe6fb47a3a3 │ ├── 76eb300208be53bf5e01e726ff9410b7 │ ├── 785669509a34c443e9985adcd7726ca7 │ ├── 78dccb1f900387b8c8f00a73f08f2a74 │ ├── 7916718a182064e785a7e348fa586b3d │ ├── 79d2bce78b9a82251a13e91a6cbd5cd3 │ ├── 7a469066b76a99876bbf3723e4199a36 │ ├── 7a916e31d2524601d8f6cffa80337547 │ ├── 7ae1ad3880a26263a7f9e22c5ede2191 │ ├── 7b352062ab815cc81d3ac1a08b2125d0 │ ├── 7bd140be051625e84487b5ca34262dab │ ├── 7cd2763bc3dbee09d4de90ca0ec40d65 │ ├── 7d276cd586d634b9f2d6c5fd52ca3844 │ ├── 7d711161d59ef2e285d742780cf857e2 │ ├── 80a68e60840ee3cc16056b90f58ce304 │ ├── 810c61d66460179160a8965c0f58bee8 │ ├── 81914ca9a3c337205e98cbcec28c6612 │ ├── 81eeaf4bfc7d77f18bf460ad1587ffa5 │ ├── 821f299345074953b4793c7c2ff0a5b4 │ ├── 833ea7953f12ebadb3e86e690783cb64 │ ├── 840396027241a5034f51027aeea75824 │ ├── 854a7f019b58a47e00e5292f3d09fcf3 │ ├── 860065ebe2a6a84ad538f7b11cf10ad7 │ ├── 860b07454eb5921bafb47acc47808bb6 │ ├── 8614a9b55fe3da904993e42f60b36f3c │ ├── 86398a8fde822df9c98e3045d5ac4928 │ ├── 8651fa56c935aa7022eb7757c7eb11d4 │ ├── 86dec675ee5c679dd90515f5441fa0ba │ ├── 8763ebaf8945908d324cdd1da0660b49 │ ├── 87df883f6d318f26f6a857ab35939df6 │ ├── 885d80812e1449909816abc93824ca63 │ ├── 8a3b890f2c55261b66b3d3666166383f │ ├── 8a6f9e14e2389d460fac8522366a38aa │ ├── 8afe8696804a22131435ec64027a1a67 │ ├── 8b0c5688926d5f9aa5ef4aff2d83a1c1 │ ├── 8bbb6190b9d26fd86243334f2d64cec7 │ ├── 8c1963032ecbdf11d9415fcc5b7649c2 │ ├── 8c8188e5b3b3830fad7f1c539f158c87 │ ├── 8d1ed05145df4646cbe68fea32d5f073 │ ├── 8e04e3fe39c13c9b23ca575b4f6b5006 │ ├── 8e2b3a4b10689b8c5fc5f7dafdb14e17 │ ├── 8f10256fd95b268c3ee15c39917cab9d │ ├── 8f32ec316b8147a4f7df0948bc1d87c1 │ ├── 903f180c3b58e71c181fa1da8cd1fea1 │ ├── 90c429494010758bbba1e5ccbf3bf22e │ ├── 912cf3e40b70e85da6df06679e13cee0 │ ├── 913f9afa26cfedeee2ddb555b42baebe │ ├── 91480a745b0811da5159692f50c98e06 │ ├── 93307d3ddf8b9e0ed7a3c91b6c7f6801 │ ├── 93bcccd1affab5fdda7951b0ad2519dd │ ├── 94d308fd2c3e3f025079b7487664e1fa │ ├── 95ea62207f4c66059d9c45231ffb07e9 │ ├── 967b29cebf70b8459d9d02243bb10eb9 │ ├── 97a1ba68e7e23f09b842d480566f15c6 │ ├── 97e795ef6d85034c8d90fc85c0717b3f │ ├── 99030513360ce58efcf6cb5836e42265 │ ├── 99485021f061e146958e352a31cff150 │ ├── 9a8d128a2cb02bbf376664643a2d4663 │ ├── 9b243ba92768c10d5afbea4ad1ce6461 │ ├── 9b63d4abd4dd9447751963d696c27670 │ ├── 9b88a66bf2176550ee514dc294bb0718 │ ├── 9b94bcee243c8df484e196fe7e064320 │ ├── 9be319902fc0db726468f7b69bf0ce1d │ ├── 9be388f12e6b8f08d9070945290764d9 │ ├── 9c0a70d5df2439364a549e2f816a70a9 │ ├── 9cce20a2da08e50af5d17899d7248e45 │ ├── 9d5b3d647ad0e351fadbd3e78f62ff4a │ ├── 9d8a26c2a25cd9604a110b34a2117bf1 │ ├── 9da87d3cc308f5bed641b0b0cc9d75ce │ ├── 9e1af4713b6d15905fdc3c5f9bbf4619 │ ├── 9e669756c6b6af8d132936f5ef1bae30 │ ├── 9e7a24dceaaba51e56b901123261ad2d │ ├── 9ec6ca010beade5de8794f0b8a6cf1f2 │ ├── 9fb7915f2ac7725445b8431081b2bedb │ ├── a03a6985f6879f83086f757649440c19 │ ├── a14c3e20a5f838d3f455fb2f0c9353ff │ ├── a18d228d7dbb9de47526cbf910ae8194 │ ├── a1b045ac219fb2cb5060e752b4ad98a0 │ ├── a2a79a405d4dfd8d54d9530cd01a8e3b │ ├── a2e400663d5b948fabdd576b07b36b6f │ ├── a3585bd5c5d7eccbe0349f54b0afdaa2 │ ├── a71e87c9ebc5a6f9f1fd53bce2974c96 │ ├── a74db82ff79fca33ab9ace33669a99e5 │ ├── a82586407b5dce3b0e8f6a3c6620680d │ ├── a83fe2e1906479bc7b94337f5b48f48d │ ├── ab6bfc017c834c4a76dcf92a29451db1 │ ├── ab6e8918af68d62a26180b7cfb435502 │ ├── aca4452a86a43f5013946be04129554a │ ├── acb378b382e78b0938880afaef72055d │ ├── acb39669ae58402dedd640c92bd01ba4 │ ├── adc0d001ea533931b54bb3e678875d78 │ ├── ae747f6e7b15891a2c230cf532444994 │ ├── aed4df024f814b3d2bdf8ec9a587c75a │ ├── af6a6f63a513f6a1c1f3ee53b3369fb2 │ ├── b0241bc01435538f42afb53ea7630a70 │ ├── b160ba1c3167f65eea978c3377e10a88 │ ├── b1ffa03dbc9d29ac7d40f1098643a69b │ ├── b2bc71a2e39068d120b84644ba37fcaa │ ├── b555238dbc39d949ac0a48c7ea8ee0f5 │ ├── b582f9ce383112a2556942cefc525d44 │ ├── b5b05b196fa259d4d694c314cfd385bf │ ├── b5bdeed6c55bf2a80f55dc5610cfaeb6 │ ├── b5bee127c4f55e78a4a7d420a3137f1c │ ├── b617831e2fb322332dad8a9c36064e9c │ ├── b8a78d5b2e725a02699a7e5ee966009e │ ├── b8dc55a63b0f2e1628ff082a6e508739 │ ├── b9109bd54fa774b46268a0e8adecc2be │ ├── b91bbcc9a4a040673ba6f8210d447e7d │ ├── b920fd8cce6d7b56ff26d5f5f69bf46c │ ├── bb9e86500867ae3e5bccb07721f40172 │ ├── bbb9dacab2fe41400fa4631b365dec84 │ ├── bc84aa4c846115e00b2734bc675afbb9 │ ├── be2762c548ce67264fcf9a247283c397 │ ├── bfe4ff310513226699011fd0dc0f1bb4 │ ├── bfe74d7f66c90bb789056b9ed16b6a74 │ ├── bfeeb10894ff9b4e8c440887efbf2c4c │ ├── c106f28bda72a95f5361c517c1367972 │ ├── c130c49a713919458f4c586807cbf6e9 │ ├── c18b95980e52ce2426273b28f3039253 │ ├── c224a41ec9dbd85830916df009733744 │ ├── c29cfee76c45b91a002a2dce4c72b8a8 │ ├── c2f0da4b728875b3394f40aad342397e │ ├── c2fe6f025500507f8389b95b3bb5e46f │ ├── c40cd4337357fd546d99582770de2600 │ ├── c5072f05fa3c2660136c8c6c40f6bda1 │ ├── c5320e92b75ce794929d311de0041b73 │ ├── c59ac9edc9de4049936316c7eb27fc54 │ ├── c5c46cc255bdf599fdd44371c967458d │ ├── c61db23d4d9de4c0aa379a645683090e │ ├── c68077f5a896fc7993ff1c3aa353fd00 │ ├── c680db12f24219bf009779b2e4dee29c │ ├── c71ce9af681d5abbe9d67103bcc17007 │ ├── c99310bef08a8927d4929f3caf8049cd │ ├── ca648bf4b562274db6b2d57c4dc7e0d8 │ ├── cd0ecb3b10cbe8af7e8e311c21171256 │ ├── cd853711f85e687e6032d40c922bbc80 │ ├── cda95bdae80688bd431f004c90712e58 │ ├── cdb460a9b0eaed7ef1e7bfb689451002 │ ├── cdfe2c5a42ad8c7f213a6c9b21236e26 │ ├── ce0166cfdf4ab11383df371b6a84f5fa │ ├── ce0e4a708f795076f5b24a658a74f969 │ ├── ce7b828a9483425d14901743bc22a9dd │ ├── ceefb547647c637dfb96f3428220bb69 │ ├── cf9fd4966ae2703f7a9c2a2ed5b0fa69 │ ├── d06bce5e0785af0f7b9445afbb7b65c7 │ ├── d0a6c1da3b091f4f7bb6793e07246638 │ ├── d5dcbae6cf9612931d703b2924d69ea3 │ ├── d60e9e653386887e98209907bbcb8cc2 │ ├── d6c9e25c18dded5148fe00f7aa424f45 │ ├── d75252fef4c4ddeba2dea39d209dd259 │ ├── d79291b7bb444334b49556cc8008e2cd │ ├── d90323737864ff187b57ab3d1bb6199f │ ├── d951dfb4a6c237f5a70f216400e9efa5 │ ├── d9d951f18d9edf763933c947d438b9b1 │ ├── da56c23c90c4f08deb733ea1a0258ca7 │ ├── db09ea1cfc170707558f3d988193600c │ ├── db15895cdc51bd24b7baf38abe9bc8f4 │ ├── db62142fa6dab8d55c4b93352f0d6280 │ ├── db6febbf355f40b97cbfba0415625cb3 │ ├── dbb46029d17e8cba9a5899608fb97e29 │ ├── dc099882a652e0d00d98a6b15ab8fb38 │ ├── dc3be75bb27787f5e96c15ac2b148f8f │ ├── ddfdcebc8695d241c3bce32538860ed8 │ ├── de1ac4b6db5c8081b6b5d474713e1ffa │ ├── dec48484b82b527578e2bcbf5690112e │ ├── decddbb210958457fdf8cccd04516650 │ ├── dfae391e4e2766909ca99f2fb12ea73f │ ├── e092b52b7c7d999cb3ff5d6025c196cf │ ├── e25625038a40ea52e468a887e7cd948a │ ├── e309dcb5d5f79d76f87fe2ce747bb38a │ ├── e31b0a25e89d8c728b4d6e88ae6bee35 │ ├── e3e320bb6fbd7bbb9e9336f4700c8edb │ ├── e40b031ea2afaa9924fe212154c1e543 │ ├── e52c473ae3a6e1a50e0c594ea43ebaad │ ├── e57472bb2de637d387e9d4a3293afec6 │ ├── e5ef1732a53ee1bbbec01e3febca1d48 │ ├── e66d83876537e69b7db09380f9c8b901 │ ├── e688b8853a0e32c6d1072f0e814772b9 │ ├── e6b30c046d75fb12e23fa9443bf18039 │ ├── e8253900e7cecf5e77b26795e8b2a7e6 │ ├── e8df893f9563a2a2caaa7269ce53f901 │ ├── e99d62692d9ca0a6a874dfa82aa927c3 │ ├── e9aa9df72dc5ec1d6582631ce11d3977 │ ├── e9afc761a80cc1fd38aa240880f8863c │ ├── ea4a4c06999bc333751f7a3f8e315146 │ ├── ec2a5b91683efdaf72ab17d4845d8f87 │ ├── ec8cff1591cc542e05b204025593f656 │ ├── ed2a51c7efee7669109b5a87e998ed44 │ ├── eff4a4b6422d673560424aeea3582786 │ ├── f0184be2bbfe3259325a06be28010772 │ ├── f06cf46fdd11d488d2e2039b02ea0871 │ ├── f11e6309497859a9ff887bfdaef8163a │ ├── f17b8d8c71b408ecc8060e90ee14c3be │ ├── f204ee584e3aff11a0643c59e14a5c67 │ ├── f2765d469cf1845ca5c9ffcc650008ff │ ├── f301d782da751c3be89cae7bf64d2971 │ ├── f35436ba635651d244fe7e997d39b1a3 │ ├── f3b2891f3b61bda3948454e27093b460 │ ├── f453abb5459a544765acb371095a7eca │ ├── f57d8229808c14b35d4d9da4b7b5083c │ ├── f691df6701a5ffcb7aa95084c8eaa0c2 │ ├── f73e4781909f47a243d477a9321b9cba │ ├── f7bfdfcad7a3b1dfb4786440cb71762c │ ├── f8862f7330d14c8e28274c4ebe3f073c │ ├── f8e6781ccccdcb7b15d279b9758e28f7 │ ├── f8fc21146e4f72712b52b46e59b54d34 │ ├── fa04700d4bc421e5ac39d59a219d34c2 │ ├── fb8fabc9c08bad5ec9784da518794f19 │ ├── fc80f82dbd1483ab989b1f8284f60f03 │ ├── fc8634d969c2b3a047e7af0eacd61036 │ ├── fca38b562ed8eb98cef1da50a09ba96b │ ├── fd830ec0bcb69a1c1c25c6b3b977d1b0 │ ├── fe1c959498ad2436d8255602c936c5f8 │ ├── fe4cee76605b020eab65bd9ff50a4f7c │ ├── fe9fe63e9fd686663f8740c3c7b3b8e9 │ ├── fea4da1497af1d3a767699fa5fd7a40c │ ├── ff8dbd7076ae267a40d513c1bfa3adbe │ └── ffcc296b9a80279494dba16ec6491aa6 └── test-promql.yaml └── test_formatter.py /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Python package 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] 18 | 19 | steps: 20 | - uses: actions/checkout@v2 21 | 22 | - name: Set up Python ${{ matrix.python-version }} 23 | uses: actions/setup-python@v1 24 | with: 25 | python-version: ${{ matrix.python-version }} 26 | 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | pip install -e .[dev] 31 | pip install black==22.6.0 32 | pip install pytest 33 | pip install PyYAML 34 | - name: validate-style 35 | run: | 36 | make validate-style 37 | 38 | - name: Tests 39 | run: | 40 | pytest tests/ 41 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | WORKDIR=build 2 | ANTLR_VERSION=4.10 3 | ANTLR_JAR=antlr-$(ANTLR_VERSION)-complete.jar 4 | 5 | PROJECT=grammars-v4 6 | GITHUB_URL=git@github.com:facetoe/$(PROJECT).git 7 | GRAMMAR_COMMIT=44d956ad79598dea81b13aad5275e55e698595e8 8 | 9 | $(WORKDIR)/$(ANTLR_JAR): 10 | mkdir -p $(WORKDIR) 11 | curl https://www.antlr.org/download/$(ANTLR_JAR) -o $(WORKDIR)/$(ANTLR_JAR) 12 | 13 | $(WORKDIR)/$(PROJECT): 14 | git clone $(GITHUB_URL) $(WORKDIR)/$(PROJECT) 15 | 16 | generate-parser: $(WORKDIR)/$(ANTLR_JAR) $(WORKDIR)/$(PROJECT) 17 | git -C $(WORKDIR)/$(PROJECT) reset --hard "$(GRAMMAR_COMMIT)" 18 | (cd $(WORKDIR)/$(PROJECT)/promql && java -jar $(CURDIR)/$(WORKDIR)/$(ANTLR_JAR) -Dlanguage=Python3 PromQLLexer.g4 -visitor -o $(CURDIR)/promformat/parser) 19 | (cd $(WORKDIR)/$(PROJECT)/promql && java -jar $(CURDIR)/$(WORKDIR)/$(ANTLR_JAR) -Dlanguage=Python3 PromQLParser.g4 -visitor -o $(CURDIR)/promformat/parser) 20 | 21 | clean: 22 | rm -rf $(WORKDIR) 23 | 24 | test: 25 | PYTHONPATH=. pytest-3 tests/ 26 | 27 | reformat: 28 | black promformat tests 29 | 30 | validate-style: 31 | $(eval CHANGES_BEFORE := $(shell mktemp)) 32 | git diff > $(CHANGES_BEFORE) 33 | $(MAKE) reformat 34 | $(eval CHANGES_AFTER := $(shell mktemp)) 35 | git diff > $(CHANGES_AFTER) 36 | diff $(CHANGES_BEFORE) $(CHANGES_AFTER) 37 | -rm $(CHANGES_BEFORE) $(CHANGES_AFTER) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Promformat 2 | 3 | Promformat is a PromQL formatter written in Python. It works by building an AST from the CST provided by ANTLR4, and then using that to produce formatted code. 4 | 5 | The result should be semantically identical to the unformatted version as promval compares the parse tree of the original and formatted expression and fails if they are not identical. 6 | 7 | # Usage 8 | 9 | From command line: 10 | ```text 11 | # Format a file containing PromQL 12 | promformat 13 | 14 | # No arguments enters interpreter 15 | promformat 16 | ``` 17 | 18 | As library: 19 | ```text 20 | from promformat import format_query 21 | print(format_query("1+1")) 22 | ``` 23 | 24 | # Example 25 | 26 | Given the PromQL: 27 | 28 | ``` 29 | job:request_latency_seconds:mean5m{job="myjob"} > 0.5 30 | ``` 31 | 32 | it will be formatted: 33 | 34 | ``` 35 | job:request_latency_seconds:mean5m 36 | { 37 | job="myjob" 38 | } > 0.5 39 | ``` 40 | 41 | A more complex example: 42 | 43 | ```text 44 | ( 45 | node_filesystem_avail_bytes * 100 46 | ) / node_filesystem_size_bytes < 10 and ON 47 | ( 48 | instance, 49 | device, 50 | mountpoint 51 | ) 52 | predict_linear 53 | ( 54 | node_filesystem_avail_bytes 55 | { 56 | # We don't care about tmpfs 57 | fstype!~"tmpfs" 58 | } [1h], 59 | 24 * 3600 60 | ) < 0 and ON 61 | ( 62 | instance, 63 | device, 64 | mountpoint 65 | ) 66 | node_filesystem_readonly == 0 67 | ``` 68 | -------------------------------------------------------------------------------- /promformat/__init__.py: -------------------------------------------------------------------------------- 1 | from antlr4 import InputStream, CommonTokenStream, BailErrorStrategy 2 | from antlr4.error.ErrorListener import ErrorListener 3 | 4 | from promformat.formatter import ( 5 | BuildAstVisitor, 6 | PromQLFormatter, 7 | ParseTreeValidator, 8 | ) 9 | from promformat.parser.PromQLLexer import PromQLLexer 10 | from promformat.parser.PromQLParser import PromQLParser 11 | 12 | 13 | class FailOnAnyErrorListener(ErrorListener): 14 | def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): 15 | raise Exception( 16 | "ERROR: when parsing line %d column %d: %s\n" % (line, column, msg) 17 | ) 18 | 19 | 20 | def format_query(promql): 21 | parse_tree = _build_cst(promql) 22 | visitor = BuildAstVisitor() 23 | abstract_syntax_tree = visitor.visit(parse_tree) 24 | 25 | formatter = PromQLFormatter() 26 | formatted_promql = formatter.format(abstract_syntax_tree) 27 | 28 | # Validate that our formatted PromQL produces the exact same parse tree. 29 | ParseTreeValidator().validate( 30 | left=parse_tree, 31 | right=_build_cst(formatted_promql), 32 | ) 33 | 34 | return formatted_promql 35 | 36 | 37 | def _build_cst(promql): 38 | input_stream = InputStream(promql) 39 | lexer = PromQLLexer(input_stream) 40 | token_stream = CommonTokenStream(lexer) 41 | promql_parser = PromQLParser(token_stream) 42 | promql_parser.addErrorListener(FailOnAnyErrorListener()) 43 | cst = promql_parser.expression() 44 | return cst 45 | -------------------------------------------------------------------------------- /promformat/__main__.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import sys 3 | from contextlib import suppress 4 | 5 | from promformat import format_query 6 | 7 | 8 | def main(): 9 | parser = argparse.ArgumentParser() 10 | parser.add_argument( 11 | "input_file", 12 | nargs="?", 13 | default=None, 14 | help="File containing PromQL to format", 15 | ) 16 | args = parser.parse_args() 17 | if args.input_file: 18 | with open(args.input_file) as f: 19 | query = f.read() 20 | result = format_query(query) 21 | print(result) 22 | else: 23 | while True: 24 | try: 25 | query = input("> ") 26 | except EOFError: 27 | sys.exit() 28 | if query: 29 | with suppress(Exception): 30 | result = format_query(query) 31 | print(result) 32 | 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /promformat/ast_nodes.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional, Union 2 | 3 | from promformat.parser.PromQLParser import PromQLParser 4 | 5 | 6 | class Expr: 7 | def __init__(self, ctx, comments=None): 8 | self.ctx = ctx 9 | self.comments = comments 10 | 11 | 12 | class Literal(Expr): 13 | def __init__(self, ctx, value): 14 | super(Literal, self).__init__(ctx) 15 | self.value = value 16 | 17 | 18 | class Number(Literal): 19 | pass 20 | 21 | 22 | class String(Literal): 23 | pass 24 | 25 | 26 | class ParensNode(Expr): 27 | def __init__(self, ctx, vector_operation): 28 | super(ParensNode, self).__init__(ctx) 29 | self.vector_operation = vector_operation 30 | 31 | 32 | class UnaryOpNode(Expr): 33 | def __init__(self, ctx, operator, operand): 34 | super(UnaryOpNode, self).__init__(ctx) 35 | self.operator = operator 36 | self.operand = operand 37 | 38 | 39 | class PowOpNode(Expr): 40 | def __init__(self, ctx, left, right, operator, grouping): 41 | super(PowOpNode, self).__init__(ctx) 42 | self.left = left 43 | self.right = right 44 | self.operator = operator 45 | self.grouping = grouping 46 | 47 | 48 | class AddOpNode(Expr): 49 | def __init__(self, ctx, left, right, operator, grouping, comments): 50 | super(AddOpNode, self).__init__(ctx, comments) 51 | self.left = left 52 | self.right = right 53 | self.operator = operator 54 | self.grouping = grouping 55 | 56 | 57 | class MultOpNode(Expr): 58 | def __init__(self, ctx, left, right, operator, grouping, comments): 59 | super(MultOpNode, self).__init__(ctx, comments) 60 | self.left = left 61 | self.right = right 62 | self.operator = operator 63 | self.grouping = grouping 64 | 65 | 66 | class CompareOperationNode(Expr): 67 | def __init__( 68 | self, 69 | ctx, 70 | left, 71 | right, 72 | operator, 73 | grouping, 74 | bool_keyword, 75 | comments=None, 76 | ): 77 | super(CompareOperationNode, self).__init__(ctx, comments=comments) 78 | self.left = left 79 | self.right = right 80 | self.operator = operator 81 | self.grouping = grouping 82 | self.bool_keyword = bool_keyword 83 | 84 | 85 | class OnIgnoring(Expr): 86 | def __init__(self, ctx, operator, labels, comments): 87 | super().__init__(ctx, comments) 88 | self.operator = operator 89 | self.labels = labels 90 | 91 | 92 | class GroupLeftRight(Expr): 93 | def __init__(self, ctx, operator, labels, comments): 94 | super().__init__(ctx, comments) 95 | self.operator = operator 96 | self.labels = labels 97 | 98 | 99 | class Grouping: 100 | def __init__(self, on_ignoring, group_left_right): 101 | self.on_ignoring = on_ignoring 102 | self.group_left_right = group_left_right 103 | 104 | 105 | class AndUnlessOperationNode(Expr): 106 | def __init__(self, ctx, left, right, operator, grouping, comments): 107 | super(AndUnlessOperationNode, self).__init__(ctx, comments) 108 | self.left = left 109 | self.right = right 110 | self.operator = operator 111 | self.grouping = grouping 112 | 113 | 114 | class OrOperationNode(Expr): 115 | def __init__(self, ctx, left, right, operator, grouping, comments): 116 | super(OrOperationNode, self).__init__(ctx, comments) 117 | self.left = left 118 | self.right = right 119 | self.operator = operator 120 | self.grouping = grouping 121 | 122 | 123 | class LabelNameNode(Expr): 124 | def __init__(self, ctx, name: str, comments=None): 125 | super(LabelNameNode, self).__init__(ctx, comments) 126 | self.name = name 127 | 128 | 129 | class LabelNode(Expr): 130 | def __init__( 131 | self, 132 | ctx: PromQLParser.LabelMatcherContext, 133 | comments, 134 | ): 135 | super(LabelNode, self).__init__(ctx, comments) 136 | self.name = ctx.labelName().getText() 137 | self.operator = ctx.labelMatcherOperator().getText() 138 | self.value = ctx.STRING().getText() 139 | 140 | 141 | class LabelList(Expr): 142 | def __init__( 143 | self, 144 | ctx, 145 | labels: List[Union[LabelNode, LabelNameNode]], 146 | has_trailing_comma: bool = False, 147 | ): 148 | super(LabelList, self).__init__(ctx) 149 | self.labels = labels 150 | self.has_trailing_comma = has_trailing_comma 151 | 152 | 153 | class OffsetNode(Expr): 154 | def __init__(self, ctx, instant_selector, offset, duration): 155 | super(OffsetNode, self).__init__(ctx) 156 | self.instant_selector = instant_selector 157 | self.offset = offset 158 | self.duration = duration 159 | 160 | 161 | class LabelMatcherNode(Expr): 162 | def __init__(self, ctx, labels: List[LabelNode]): 163 | super(LabelMatcherNode, self).__init__(ctx) 164 | self.labels = labels 165 | 166 | def __len__(self): 167 | return len(self.labels) 168 | 169 | 170 | class InstantSelectorNode(Expr): 171 | def __init__( 172 | self, ctx, metric_name: str, labels: List[LabelNode], left_brace, right_brace 173 | ): 174 | super(InstantSelectorNode, self).__init__(ctx) 175 | self.metric_name = metric_name 176 | self.labels = labels 177 | self.left_brace = left_brace 178 | self.right_brace = right_brace 179 | 180 | 181 | class SubqueryRangeNode(Expr): 182 | def __init__(self, ctx, subquery_range: str, offset): 183 | super(SubqueryRangeNode, self).__init__(ctx=ctx) 184 | self.subquery_range = subquery_range 185 | self.offset = offset 186 | 187 | 188 | class SubqueryNode(Expr): 189 | def __init__(self, ctx, left, subquery_range): 190 | super(SubqueryNode, self).__init__(ctx) 191 | self.left = left 192 | self.subquery_range = subquery_range 193 | 194 | 195 | class MatrixSelectorNode(Expr): 196 | def __init__(self, ctx, selector: InstantSelectorNode, time_range): 197 | super(MatrixSelectorNode, self).__init__(ctx) 198 | self.selector = selector 199 | self.time_range = time_range 200 | 201 | 202 | class AggregationNode(Expr): 203 | def __init__( 204 | self, 205 | ctx, 206 | operator: str, 207 | by_without: Optional["ByWithoutNode"], 208 | parameter_list, 209 | is_prefix, 210 | ): 211 | super(AggregationNode, self).__init__(ctx) 212 | self.operator = operator 213 | self.by_without = by_without 214 | self.parameter_list = parameter_list 215 | self.is_prefix = is_prefix 216 | 217 | 218 | class ByWithoutNode: 219 | def __init__( 220 | self, 221 | group_operator: Optional[str], 222 | group_label_list: LabelList, 223 | comments=None, 224 | ): 225 | self.group_operator = group_operator 226 | self.group_label_list = group_label_list 227 | self.comments = comments 228 | 229 | 230 | class MetricNameNode(Expr): 231 | def __init__(self, ctx, metric_name): 232 | super(MetricNameNode, self).__init__(ctx) 233 | self.metric_name = metric_name 234 | 235 | 236 | class FunctionNode(Expr): 237 | def __init__(self, ctx: PromQLParser.Function_Context, parameters): 238 | super(FunctionNode, self).__init__(ctx) 239 | self.ctx = ctx 240 | self.parameters = parameters 241 | self.name = self.ctx.FUNCTION().getText() 242 | 243 | 244 | class Parameter: 245 | def __init__(self, value): 246 | self.value = value 247 | 248 | 249 | class ParameterListNode(Expr): 250 | def __init__(self, ctx, parameters: List[Parameter]): 251 | super().__init__(ctx) 252 | self.parameters = parameters 253 | -------------------------------------------------------------------------------- /promformat/buffer.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | 4 | class SmartBuffer(io.StringIO): 5 | def peek(self, n: int): 6 | curr_pos = self.tell() 7 | data = self.read(n) 8 | self.seek(curr_pos) 9 | return data 10 | 11 | def chomp_newline(self): 12 | end = self.seek(0, io.SEEK_END) 13 | if end > 0: 14 | last_char_pos = end - 1 15 | self.seek(last_char_pos) 16 | if self.peek(1) == "\n": 17 | self.truncate(last_char_pos) 18 | self.seek(last_char_pos) 19 | self.write(" ") 20 | 21 | def strip(self): 22 | end_pos = self.seek(0, io.SEEK_END) 23 | while end_pos > 0: 24 | self.seek(end_pos) 25 | if self.peek(1) not in (" ", "", "\n"): 26 | self.truncate(end_pos + 1) 27 | self.seek(end_pos + 1) 28 | return 29 | end_pos -= 1 30 | 31 | def __str__(self): 32 | return self.getvalue() 33 | 34 | def __repr__(self): 35 | return repr(str(self)) 36 | -------------------------------------------------------------------------------- /promformat/error.py: -------------------------------------------------------------------------------- 1 | class FormatError(Exception): 2 | pass 3 | 4 | 5 | class UnEqualParseTreeError(Exception): 6 | pass 7 | -------------------------------------------------------------------------------- /promformat/formatter.py: -------------------------------------------------------------------------------- 1 | import functools 2 | from contextlib import contextmanager 3 | from typing import Optional 4 | 5 | from antlr4 import ErrorNode, TerminalNode, CommonTokenStream, ParserRuleContext 6 | from antlr4.Token import CommonToken 7 | 8 | from promformat.ast_nodes import ( 9 | Number, 10 | MultOpNode, 11 | String, 12 | FunctionNode, 13 | LabelNode, 14 | InstantSelectorNode, 15 | MatrixSelectorNode, 16 | AggregationNode, 17 | LabelNameNode, 18 | SubqueryRangeNode, 19 | SubqueryNode, 20 | MetricNameNode, 21 | CompareOperationNode, 22 | AndUnlessOperationNode, 23 | OrOperationNode, 24 | UnaryOpNode, 25 | AddOpNode, 26 | Grouping, 27 | PowOpNode, 28 | ParensNode, 29 | OnIgnoring, 30 | GroupLeftRight, 31 | OffsetNode, 32 | LabelList, 33 | Parameter, 34 | ParameterListNode, 35 | ByWithoutNode, 36 | ) 37 | from promformat.buffer import SmartBuffer 38 | from promformat.error import UnEqualParseTreeError 39 | from promformat.parser.PromQLParser import PromQLParser 40 | from promformat.parser.PromQLParserVisitor import PromQLParserVisitor 41 | 42 | SENTINEL = object() 43 | 44 | 45 | class ParseTreeValidator: 46 | def validate(self, left, right): 47 | if type(left) != type(right): 48 | raise UnEqualParseTreeError( 49 | f"Expected: {type(left).__name__}, found: {type(right).__name__}" 50 | ) 51 | elif left.getText() != right.getText(): 52 | raise UnEqualParseTreeError( 53 | f"Expected:\n{left.getText()}\nFound:\n{right.getText()}\n" 54 | ) 55 | if isinstance(left, (ErrorNode, TerminalNode)): 56 | return 57 | left_children, right_children = left.getChildren(), right.getChildren() 58 | for left, right in zip(left_children, right_children): 59 | if type(left) != type(right): 60 | raise UnEqualParseTreeError( 61 | f"Expected: {type(left).__name__}, found: {type(right).__name__} on child" 62 | ) 63 | self.validate(left, right) 64 | 65 | left_empty, right_empty = ( 66 | next(left_children, SENTINEL) == SENTINEL, 67 | next(right_children, SENTINEL) == SENTINEL, 68 | ) 69 | if not left_empty: 70 | raise UnEqualParseTreeError( 71 | f"Node: {type(left).__name__} has extra children" 72 | ) 73 | if not right_empty: 74 | raise UnEqualParseTreeError( 75 | f"Node: {type(right).__name__} has extra children" 76 | ) 77 | 78 | 79 | class BuildAstVisitor(PromQLParserVisitor): 80 | def __init__(self): 81 | self.prev_index = 0 82 | 83 | def visit(self, ctx): 84 | result = super().visit(ctx) 85 | if ctx.start.tokenIndex != self.prev_index: 86 | comment_tokens = self._extract_comments_from_context(ctx) 87 | if comment_tokens: 88 | result.comments = comment_tokens 89 | self.prev_index = ctx.start.tokenIndex 90 | return result 91 | 92 | def visitExpression(self, ctx: PromQLParser.ExpressionContext): 93 | return self.visit(ctx.vectorOperation()) 94 | 95 | def visitVectorOperation(self, ctx: PromQLParser.VectorOperationContext): 96 | if ctx.powOp(): 97 | left, right = self._extract_left_right_vector_operations(ctx) 98 | op = ctx.powOp().POW().getText() 99 | grouping = self._extract_grouping(grouping=ctx.powOp().grouping()) 100 | return PowOpNode( 101 | ctx, 102 | left=left, 103 | right=right, 104 | operator=op, 105 | grouping=grouping, 106 | ) 107 | elif ctx.addOp(): 108 | left, right = self._extract_left_right_vector_operations(ctx) 109 | op_codes = ("ADD", "SUB") 110 | context = ctx.addOp() 111 | op = self._extract_op(context, op_codes) 112 | grouping = self._extract_grouping(grouping=context.grouping()) 113 | return AddOpNode( 114 | ctx, 115 | left=left, 116 | right=right, 117 | operator=op.getText(), 118 | grouping=grouping, 119 | comments=self._extract_comments_from_context(context), 120 | ) 121 | elif ctx.unaryOp(): 122 | vector = ctx.vectorOperation() 123 | assert len(vector) == 1 124 | operand = self.visit(vector[0]) 125 | context = ctx.unaryOp() 126 | op_codes = ("ADD", "SUB") 127 | op = self._extract_op(context, op_codes) 128 | return UnaryOpNode( 129 | ctx, 130 | operator=op.getText(), 131 | operand=operand, 132 | ) 133 | elif ctx.multOp(): 134 | left, right = self._extract_left_right_vector_operations(ctx) 135 | context = ctx.multOp() 136 | op_codes = ("MOD", "DIV", "MULT") 137 | op = self._extract_op(context, op_codes) 138 | grouping = self._extract_grouping(grouping=context.grouping()) 139 | return MultOpNode( 140 | ctx, 141 | left=left, 142 | right=right, 143 | operator=op.getText(), 144 | grouping=grouping, 145 | comments=self._extract_comments_from_context(context), 146 | ) 147 | elif ctx.subqueryOp(): 148 | subquery = self.visit(ctx.subqueryOp()) 149 | assert len(ctx.vectorOperation()) == 1 150 | vector_op = ctx.vectorOperation()[0] 151 | left = self.visit(vector_op) 152 | return SubqueryNode(ctx, left=left, subquery_range=subquery) 153 | elif ctx.compareOp(): 154 | context = ctx.compareOp() 155 | left, right = self._extract_left_right_vector_operations(ctx) 156 | op_codes = ("DEQ", "GT", "LT", "GE", "LE", "NE", "BOOL") 157 | op = self._extract_op(context, op_codes) 158 | grouping = self._extract_grouping(grouping=context.grouping()) 159 | bool_keyword = None 160 | if context.BOOL(): 161 | bool_keyword = context.BOOL().getText() 162 | return CompareOperationNode( 163 | context, 164 | left=left, 165 | right=right, 166 | operator=op.getText(), 167 | grouping=grouping, 168 | bool_keyword=bool_keyword, 169 | comments=self._extract_comments_from_context(context), 170 | ) 171 | elif ctx.andUnlessOp(): 172 | left, right = self._extract_left_right_vector_operations(ctx) 173 | context = ctx.andUnlessOp() 174 | op_codes = ("AND", "UNLESS") 175 | op = self._extract_op(context, op_codes) 176 | grouping = self._extract_grouping(grouping=context.grouping()) 177 | return AndUnlessOperationNode( 178 | ctx, 179 | left=left, 180 | right=right, 181 | operator=op.getText(), 182 | grouping=grouping, 183 | comments=self._extract_comments_from_context(context), 184 | ) 185 | elif ctx.orOp(): 186 | left, right = self._extract_left_right_vector_operations(ctx) 187 | context = ctx.orOp() 188 | grouping = self._extract_grouping(grouping=context.grouping()) 189 | return OrOperationNode( 190 | ctx, 191 | left=left, 192 | right=right, 193 | operator=context.OR().getText(), 194 | grouping=grouping, 195 | comments=self._extract_comments_from_context(context), 196 | ) 197 | else: 198 | return self.visit(ctx.vector()) 199 | 200 | def _extract_left_right_vector_operations(self, ctx): 201 | assert len(ctx.vectorOperation()) == 2 202 | left_op, right_op = ctx.vectorOperation() 203 | left = self.visit(left_op) 204 | right = self.visit(right_op) 205 | return left, right 206 | 207 | def _extract_grouping(self, grouping): 208 | if grouping is None: 209 | return None 210 | assert grouping.on_() or grouping.ignoring() 211 | on_ignoring = self.visitOnIgnoring(grouping) 212 | 213 | group_left_right = None 214 | if grouping.groupLeft(): 215 | context = grouping.groupLeft() 216 | group_left_right = GroupLeftRight( 217 | ctx=context, 218 | operator="group_left", 219 | labels=self.visit(context.labelNameList()), 220 | comments=self._extract_comments_from_context(context), 221 | ) 222 | elif grouping.groupRight(): 223 | context = grouping.groupRight() 224 | group_left_right = GroupLeftRight( 225 | ctx=context, 226 | operator="group_right", 227 | labels=self.visit(context.labelNameList()), 228 | comments=self._extract_comments_from_context(context), 229 | ) 230 | 231 | return Grouping( 232 | on_ignoring=on_ignoring, 233 | group_left_right=group_left_right, 234 | ) 235 | 236 | def visitOnIgnoring(self, grouping): 237 | comments = self._extract_comments_from_context(grouping) 238 | if grouping.on_(): 239 | context = grouping.on_() 240 | on_ignoring = OnIgnoring( 241 | ctx=context, 242 | operator=context.ON().getText(), 243 | labels=self.visit(context.labelNameList()), 244 | comments=comments, 245 | ) 246 | else: 247 | context = grouping.ignoring() 248 | on_ignoring = OnIgnoring( 249 | ctx=context, 250 | operator=context.IGNORING().getText(), 251 | labels=self.visit(context.labelNameList()), 252 | comments=comments, 253 | ) 254 | return on_ignoring 255 | 256 | def _extract_op(self, context, op_codes): 257 | for op_code in op_codes: 258 | op = getattr(context, op_code)() 259 | if op is not None: 260 | break 261 | else: 262 | raise Exception("Expected to find op but didn't") 263 | return op 264 | 265 | def visitSubqueryOp(self, ctx: PromQLParser.SubqueryOpContext): 266 | offset = None 267 | if ctx.offsetOp(): 268 | offset = f"{ctx.offsetOp().OFFSET().getText()} {ctx.offsetOp().DURATION().getText()}" 269 | return SubqueryRangeNode( 270 | ctx, 271 | ctx.SUBQUERY_RANGE().getText(), 272 | offset=offset, 273 | ) 274 | 275 | def visitVector(self, ctx: PromQLParser.VectorContext): 276 | if ctx.function_(): 277 | return self.visit(ctx.function_()) 278 | elif ctx.aggregation(): 279 | return self.visit(ctx.aggregation()) 280 | elif ctx.instantSelector(): 281 | return self.visit(ctx.instantSelector()) 282 | elif ctx.matrixSelector(): 283 | return self.visit(ctx.matrixSelector()) 284 | elif ctx.offset(): 285 | return self.visit(ctx.offset()) 286 | elif ctx.literal(): 287 | return self.visit(ctx.literal()) 288 | elif ctx.parens(): 289 | return self.visit(ctx.parens()) 290 | 291 | def visitOffset(self, ctx: PromQLParser.OffsetContext): 292 | selector = self.visit(ctx.instantSelector() or ctx.matrixSelector()) 293 | return OffsetNode( 294 | ctx, 295 | instant_selector=selector, 296 | offset=ctx.OFFSET().getText(), 297 | duration=ctx.DURATION().getText(), 298 | ) 299 | 300 | def visitParens(self, ctx: PromQLParser.ParensContext): 301 | vector_operation = self.visit(ctx.vectorOperation()) 302 | return ParensNode(ctx, vector_operation=vector_operation) 303 | 304 | def visitAggregation(self, ctx: PromQLParser.AggregationContext): 305 | operator = ctx.AGGREGATION_OPERATOR().getText() 306 | by_without = None 307 | if ctx.byWithout(): 308 | by_without = self.visit(ctx.byWithout()) 309 | parameter_list = self.visit(ctx.parameterList()) 310 | return AggregationNode( 311 | ctx=ctx, 312 | operator=operator, 313 | by_without=by_without, 314 | parameter_list=parameter_list, 315 | is_prefix=ctx.prefix is not None, 316 | ) 317 | 318 | def visitByWithout(self, ctx: PromQLParser.ByWithoutContext): 319 | group_operator = None 320 | group_label_list = [] 321 | if ctx.by(): 322 | group_operator = ctx.by().BY().getText() 323 | group_label_list = self.visit(ctx.by().labelNameList()) 324 | elif ctx.without(): 325 | group_operator = ctx.without().WITHOUT().getText() 326 | group_label_list = self.visit(ctx.without().labelNameList()) 327 | assert group_operator 328 | 329 | return ByWithoutNode( 330 | group_operator=group_operator, 331 | group_label_list=group_label_list, 332 | comments=self._extract_comments_from_context(ctx), 333 | ) 334 | 335 | def visitParameterList(self, ctx: PromQLParser.ParameterListContext): 336 | parameters = [] 337 | for param in ctx.parameter(): 338 | value = self.visit(param) 339 | parameters.append(Parameter(value=value)) 340 | return ParameterListNode(ctx=ctx, parameters=parameters) 341 | 342 | def visitMatrixSelector(self, ctx: PromQLParser.MatrixSelectorContext): 343 | if ctx.instantSelector(): 344 | selector = self.visit(ctx.instantSelector()) 345 | return MatrixSelectorNode( 346 | ctx=ctx, 347 | selector=selector, 348 | time_range=ctx.TIME_RANGE().getText(), 349 | ) 350 | 351 | def visitInstantSelector(self, ctx: PromQLParser.InstantSelectorContext): 352 | labels = [] 353 | if ctx.labelMatcherList(): 354 | labels = self.visit(ctx.labelMatcherList()) 355 | metric_name = "" 356 | if ctx.METRIC_NAME(): 357 | metric_name = ctx.METRIC_NAME().getText() 358 | 359 | left_brace, right_brace = None, None 360 | if ctx.LEFT_BRACE() and ctx.RIGHT_BRACE(): 361 | left_brace = ctx.LEFT_BRACE().getText() 362 | right_brace = ctx.RIGHT_BRACE().getText() 363 | return InstantSelectorNode( 364 | ctx, 365 | metric_name=metric_name, 366 | labels=labels, 367 | left_brace=left_brace, 368 | right_brace=right_brace, 369 | ) 370 | 371 | def visitLabelMatcherList(self, ctx: PromQLParser.LabelMatcherListContext): 372 | labels = [] 373 | for matcher in ctx.labelMatcher(): 374 | labels.append(self.visit(matcher)) 375 | has_trailing_comma = len(labels) == len(ctx.COMMA()) 376 | return LabelList(ctx, labels=labels, has_trailing_comma=has_trailing_comma) 377 | 378 | def visitLabelNameList(self, ctx: PromQLParser.LabelNameListContext): 379 | labels = [] 380 | for label in ctx.labelName(): 381 | if label.METRIC_NAME(): 382 | name = label.METRIC_NAME().getText() 383 | elif label.LABEL_NAME(): 384 | name = label.LABEL_NAME().getText() 385 | else: 386 | name = label.keyword().getText() 387 | assert name is not None 388 | comments = self._extract_comments_from_context(label) 389 | labels.append(LabelNameNode(ctx, name=name, comments=comments)) 390 | return LabelList(ctx, labels) 391 | 392 | def visitLabelMatcher(self, ctx: PromQLParser.LabelMatcherContext): 393 | comment_tokens = self._extract_comments_from_context(ctx) 394 | return LabelNode(ctx, comments=comment_tokens) 395 | 396 | def _extract_comments_from_context(self, ctx): 397 | stream: CommonTokenStream = ctx.parser.getInputStream() 398 | index = ctx.start.tokenIndex 399 | comment_tokens = stream.getHiddenTokensToLeft(index, channel=3) 400 | if comment_tokens: 401 | return [c.text.strip() for c in comment_tokens] 402 | 403 | def visitFunction_(self, ctx: PromQLParser.Function_Context): 404 | parameters = [] 405 | for parameter in ctx.parameter(): 406 | param = self.visit(parameter) 407 | if param is not None: 408 | parameters.append(Parameter(value=param)) 409 | return FunctionNode( 410 | ctx=ctx, 411 | parameters=ParameterListNode(ctx, parameters=parameters), 412 | ) 413 | 414 | def visitParameter(self, ctx: PromQLParser.ParameterContext): 415 | if ctx.literal(): 416 | return self.visit(ctx.literal()) 417 | elif ctx.vectorOperation(): 418 | return self.visit(ctx.vectorOperation()) 419 | 420 | def visitLiteral(self, ctx: PromQLParser.LiteralContext): 421 | if ctx.NUMBER(): 422 | return Number(ctx=ctx, value=ctx.getText()) 423 | if ctx.STRING(): 424 | return String(ctx=ctx, value=ctx.getText()) 425 | 426 | 427 | def skip_comment(): 428 | def outer(func): 429 | func.skip_comment = True 430 | 431 | @functools.wraps(func) 432 | def inner(*args, **kwargs) -> None: 433 | return func(*args, **kwargs) 434 | 435 | return inner 436 | 437 | return outer 438 | 439 | 440 | class PromQLFormatter: 441 | def __init__(self): 442 | self.indent = 0 443 | self.buffer: Optional[SmartBuffer] = None 444 | 445 | def format(self, tree): 446 | with SmartBuffer() as buff: 447 | self.buffer = buff 448 | self.visit(tree) 449 | return buff.getvalue() 450 | 451 | def visit(self, node): 452 | method_name = f"visit{type(node).__name__}" 453 | method = self.__getattribute__(method_name) 454 | if not hasattr(method, "skip_comment"): 455 | self._write_comments(node) 456 | result = method(node) 457 | return result 458 | 459 | def write(self, *output, suffix="", end=None): 460 | indent = " " * self.indent 461 | if end is not None: 462 | indent = "" 463 | line = indent + " ".join(output) + suffix 464 | print(line, end=end, file=self.buffer) 465 | 466 | def write_no_indent(self, *output): 467 | print(" ".join(output), file=self.buffer) 468 | 469 | @contextmanager 470 | def indent_block(self): 471 | self.indent += 1 472 | yield 473 | self.indent -= 1 474 | 475 | @contextmanager 476 | def no_indent(self): 477 | old_indent = self.indent 478 | self.indent = 0 479 | yield 480 | self.indent = old_indent 481 | 482 | def visitPowOpNode(self, node: PowOpNode): 483 | self._write_op_with_grouping(node) 484 | 485 | @skip_comment() 486 | def visitAddOpNode(self, node: AddOpNode): 487 | self._write_op_with_grouping(node) 488 | 489 | def visitUnaryOpNode(self, node: UnaryOpNode): 490 | self.write(node.operator, end="") 491 | self.visit(node.operand) 492 | 493 | @skip_comment() 494 | def visitMultOpNode(self, node: MultOpNode): 495 | self._write_op_with_grouping(node) 496 | 497 | @skip_comment() 498 | def visitOrOperationNode(self, node: OrOperationNode): 499 | self._write_op_with_grouping(node) 500 | 501 | @skip_comment() 502 | def visitCompareOperationNode(self, node: CompareOperationNode): 503 | self._write_op_with_grouping(node, bool_keyword=node.bool_keyword) 504 | 505 | @skip_comment() 506 | def visitAndUnlessOperationNode(self, node: AndUnlessOperationNode): 507 | self._write_op_with_grouping(node) 508 | 509 | def visitNumber(self, node: Number): 510 | self.write(node.value) 511 | 512 | def visitString(self, node: Number): 513 | self.write(node.value) 514 | 515 | def visitParensNode(self, node: ParensNode): 516 | self.write("(") 517 | with self.indent_block(): 518 | self.visit(node.vector_operation) 519 | self.write(")") 520 | 521 | def visitOffsetNode(self, node: OffsetNode): 522 | self.visit(node.instant_selector) 523 | self.write(node.offset, node.duration) 524 | 525 | def visitFunctionNode(self, node: FunctionNode): 526 | self.write(node.name) 527 | self.visitParameterListNode(node.parameters) 528 | 529 | def visitAggregationNode(self, node: AggregationNode): 530 | self.write(node.operator) 531 | if node.is_prefix: 532 | if node.by_without: 533 | self.buffer.chomp_newline() 534 | self._write_comments(node.by_without) 535 | self.write_no_indent(node.by_without.group_operator) 536 | self.write("(") 537 | with self.indent_block(): 538 | self._write_comma_seperated_list( 539 | node.by_without.group_label_list, 540 | format_func=lambda label: f"{label.name}", 541 | ) 542 | self.write(")") 543 | 544 | if node.parameter_list: 545 | self.visitParameterListNode(node.parameter_list) 546 | if not node.is_prefix: 547 | if node.by_without: 548 | self._write_comments(node.by_without) 549 | self.write(node.by_without.group_operator) 550 | self.write("(") 551 | with self.indent_block(): 552 | self._write_comma_seperated_list( 553 | node.by_without.group_label_list, 554 | format_func=lambda label: f"{label.name}", 555 | ) 556 | self.write(")") 557 | 558 | def visitSubqueryNode(self, node: SubqueryNode): 559 | with self.indent_block(): 560 | self.visit(node.left) 561 | self.visit(node.subquery_range) 562 | 563 | def visitMatrixSelectorNode(self, node: MatrixSelectorNode): 564 | self.visit(node.selector) 565 | self.buffer.chomp_newline() 566 | with self.no_indent(): 567 | self.write(node.time_range) 568 | 569 | def visitInstantSelectorNode(self, node: InstantSelectorNode): 570 | self.write(node.metric_name) 571 | if node.left_brace: 572 | self.write(node.left_brace) 573 | if node.labels: 574 | with self.indent_block(): 575 | self._write_comma_seperated_list( 576 | node.labels, 577 | format_func=lambda label: f"{label.name}{label.operator}{label.value}", 578 | ) 579 | if node.right_brace: 580 | self.write(node.right_brace) 581 | 582 | def visitMetricNameNode(self, node: MetricNameNode): 583 | self.write(node.metric_name) 584 | 585 | def visitSubqueryRangeNode(self, node: SubqueryRangeNode): 586 | self.buffer.chomp_newline() 587 | with self.no_indent(): 588 | offset = node.offset or "" 589 | self.write(node.subquery_range, end=None if offset else "") 590 | if offset: 591 | self.write(node.offset) 592 | 593 | def _write_op_with_grouping(self, node, bool_keyword=None): 594 | self.visit(node.left) 595 | self.buffer.chomp_newline() 596 | self._write_comments(node) 597 | self.write(node.operator, suffix=" ", end="") 598 | if bool_keyword is not None: 599 | with self.no_indent(): 600 | self.write(bool_keyword, end=" ") 601 | if node.grouping: 602 | self._write_comments(node.grouping.on_ignoring) 603 | self.write(node.grouping.on_ignoring.operator) 604 | self.write("(") 605 | with self.indent_block(): 606 | self._write_comma_seperated_list( 607 | label_list=node.grouping.on_ignoring.labels, 608 | format_func=lambda label: label.name, 609 | ) 610 | self.write(")") 611 | if node.grouping.group_left_right: 612 | self._write_comments(node.grouping.group_left_right) 613 | self.write(node.grouping.group_left_right.operator) 614 | self.write("(") 615 | with self.indent_block(): 616 | self._write_comma_seperated_list( 617 | label_list=node.grouping.group_left_right.labels, 618 | format_func=lambda label: label.name, 619 | ) 620 | self.write(")") 621 | with self.no_indent(): 622 | self.visit(node.right) 623 | 624 | def visitParameterListNode(self, parameter_list: ParameterListNode): 625 | param_len = len(parameter_list.parameters) 626 | self._write_comments(parameter_list) 627 | self.write("(") 628 | for index, param in enumerate(parameter_list.parameters): 629 | with self.indent_block(): 630 | self.visit(param.value) 631 | if index + 1 != param_len: 632 | self.buffer.strip() 633 | self.write_no_indent(",") 634 | self.write(")") 635 | 636 | def _write_comma_seperated_list(self, label_list: LabelList, format_func): 637 | self._write_comments(label_list) 638 | items_len = len(label_list.labels) 639 | for index, item in enumerate(label_list.labels, start=1): 640 | suffix = "," 641 | if index == items_len and not label_list.has_trailing_comma: 642 | suffix = "" 643 | output = format_func(item) 644 | self._write_comments(item) 645 | self.write(output, suffix=suffix) 646 | 647 | def _write_comments(self, item): 648 | if item.comments: 649 | for comment in item.comments: 650 | self.write(comment) 651 | -------------------------------------------------------------------------------- /promformat/parser/PromQLLexer.tokens: -------------------------------------------------------------------------------- 1 | NUMBER=1 2 | STRING=2 3 | ADD=3 4 | SUB=4 5 | MULT=5 6 | DIV=6 7 | MOD=7 8 | POW=8 9 | AND=9 10 | OR=10 11 | UNLESS=11 12 | EQ=12 13 | DEQ=13 14 | NE=14 15 | GT=15 16 | LT=16 17 | GE=17 18 | LE=18 19 | RE=19 20 | NRE=20 21 | BY=21 22 | WITHOUT=22 23 | ON=23 24 | IGNORING=24 25 | GROUP_LEFT=25 26 | GROUP_RIGHT=26 27 | OFFSET=27 28 | BOOL=28 29 | AGGREGATION_OPERATOR=29 30 | FUNCTION=30 31 | LEFT_BRACE=31 32 | RIGHT_BRACE=32 33 | LEFT_PAREN=33 34 | RIGHT_PAREN=34 35 | LEFT_BRACKET=35 36 | RIGHT_BRACKET=36 37 | COMMA=37 38 | SUBQUERY_RANGE=38 39 | TIME_RANGE=39 40 | DURATION=40 41 | METRIC_NAME=41 42 | LABEL_NAME=42 43 | WS=43 44 | SL_COMMENT=44 45 | '+'=3 46 | '-'=4 47 | '*'=5 48 | '/'=6 49 | '%'=7 50 | '^'=8 51 | 'and'=9 52 | 'or'=10 53 | 'unless'=11 54 | '='=12 55 | '=='=13 56 | '!='=14 57 | '>'=15 58 | '<'=16 59 | '>='=17 60 | '<='=18 61 | '=~'=19 62 | '!~'=20 63 | 'by'=21 64 | 'without'=22 65 | 'on'=23 66 | 'ignoring'=24 67 | 'group_left'=25 68 | 'group_right'=26 69 | 'offset'=27 70 | 'bool'=28 71 | '{'=31 72 | '}'=32 73 | '('=33 74 | ')'=34 75 | '['=35 76 | ']'=36 77 | ','=37 78 | -------------------------------------------------------------------------------- /promformat/parser/PromQLParser.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | null 4 | null 5 | '+' 6 | '-' 7 | '*' 8 | '/' 9 | '%' 10 | '^' 11 | 'and' 12 | 'or' 13 | 'unless' 14 | '=' 15 | '==' 16 | '!=' 17 | '>' 18 | '<' 19 | '>=' 20 | '<=' 21 | '=~' 22 | '!~' 23 | 'by' 24 | 'without' 25 | 'on' 26 | 'ignoring' 27 | 'group_left' 28 | 'group_right' 29 | 'offset' 30 | 'bool' 31 | null 32 | null 33 | '{' 34 | '}' 35 | '(' 36 | ')' 37 | '[' 38 | ']' 39 | ',' 40 | null 41 | null 42 | null 43 | null 44 | null 45 | null 46 | null 47 | 48 | token symbolic names: 49 | null 50 | NUMBER 51 | STRING 52 | ADD 53 | SUB 54 | MULT 55 | DIV 56 | MOD 57 | POW 58 | AND 59 | OR 60 | UNLESS 61 | EQ 62 | DEQ 63 | NE 64 | GT 65 | LT 66 | GE 67 | LE 68 | RE 69 | NRE 70 | BY 71 | WITHOUT 72 | ON 73 | IGNORING 74 | GROUP_LEFT 75 | GROUP_RIGHT 76 | OFFSET 77 | BOOL 78 | AGGREGATION_OPERATOR 79 | FUNCTION 80 | LEFT_BRACE 81 | RIGHT_BRACE 82 | LEFT_PAREN 83 | RIGHT_PAREN 84 | LEFT_BRACKET 85 | RIGHT_BRACKET 86 | COMMA 87 | SUBQUERY_RANGE 88 | TIME_RANGE 89 | DURATION 90 | METRIC_NAME 91 | LABEL_NAME 92 | WS 93 | SL_COMMENT 94 | 95 | rule names: 96 | expression 97 | vectorOperation 98 | unaryOp 99 | powOp 100 | multOp 101 | addOp 102 | compareOp 103 | andUnlessOp 104 | orOp 105 | vectorMatchOp 106 | subqueryOp 107 | offsetOp 108 | vector 109 | parens 110 | instantSelector 111 | labelMatcher 112 | labelMatcherOperator 113 | labelMatcherList 114 | matrixSelector 115 | offset 116 | function_ 117 | parameter 118 | parameterList 119 | aggregation 120 | by 121 | without 122 | byWithout 123 | grouping 124 | on_ 125 | ignoring 126 | groupLeft 127 | groupRight 128 | labelName 129 | labelNameList 130 | keyword 131 | literal 132 | 133 | 134 | atn: 135 | [4, 1, 44, 312, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 81, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 113, 8, 1, 10, 1, 12, 1, 116, 9, 1, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 122, 8, 3, 1, 4, 1, 4, 3, 4, 126, 8, 4, 1, 5, 1, 5, 3, 5, 130, 8, 5, 1, 6, 1, 6, 3, 6, 134, 8, 6, 1, 6, 3, 6, 137, 8, 6, 1, 7, 1, 7, 3, 7, 141, 8, 7, 1, 8, 1, 8, 3, 8, 145, 8, 8, 1, 9, 1, 9, 3, 9, 149, 8, 9, 1, 10, 1, 10, 3, 10, 153, 8, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 165, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 3, 14, 174, 8, 14, 1, 14, 3, 14, 177, 8, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 183, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 5, 17, 194, 8, 17, 10, 17, 12, 17, 197, 9, 17, 1, 17, 3, 17, 200, 8, 17, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 213, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 5, 20, 220, 8, 20, 10, 20, 12, 20, 223, 9, 20, 3, 20, 225, 8, 20, 1, 20, 1, 20, 1, 21, 1, 21, 3, 21, 231, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 237, 8, 22, 10, 22, 12, 22, 240, 9, 22, 3, 22, 242, 8, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 256, 8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 3, 26, 266, 8, 26, 1, 27, 1, 27, 3, 27, 270, 8, 27, 1, 27, 1, 27, 3, 27, 274, 8, 27, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 3, 30, 284, 8, 30, 1, 31, 1, 31, 3, 31, 288, 8, 31, 1, 32, 1, 32, 1, 32, 3, 32, 293, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 5, 33, 299, 8, 33, 10, 33, 12, 33, 302, 9, 33, 3, 33, 304, 8, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 0, 1, 2, 36, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 0, 8, 1, 0, 3, 4, 1, 0, 5, 7, 1, 0, 13, 18, 2, 0, 9, 9, 11, 11, 2, 0, 11, 11, 23, 23, 3, 0, 12, 12, 14, 14, 19, 20, 2, 0, 9, 11, 21, 30, 1, 0, 1, 2, 322, 0, 72, 1, 0, 0, 0, 2, 80, 1, 0, 0, 0, 4, 117, 1, 0, 0, 0, 6, 119, 1, 0, 0, 0, 8, 123, 1, 0, 0, 0, 10, 127, 1, 0, 0, 0, 12, 131, 1, 0, 0, 0, 14, 138, 1, 0, 0, 0, 16, 142, 1, 0, 0, 0, 18, 146, 1, 0, 0, 0, 20, 150, 1, 0, 0, 0, 22, 154, 1, 0, 0, 0, 24, 164, 1, 0, 0, 0, 26, 166, 1, 0, 0, 0, 28, 182, 1, 0, 0, 0, 30, 184, 1, 0, 0, 0, 32, 188, 1, 0, 0, 0, 34, 190, 1, 0, 0, 0, 36, 201, 1, 0, 0, 0, 38, 212, 1, 0, 0, 0, 40, 214, 1, 0, 0, 0, 42, 230, 1, 0, 0, 0, 44, 232, 1, 0, 0, 0, 46, 255, 1, 0, 0, 0, 48, 257, 1, 0, 0, 0, 50, 260, 1, 0, 0, 0, 52, 265, 1, 0, 0, 0, 54, 269, 1, 0, 0, 0, 56, 275, 1, 0, 0, 0, 58, 278, 1, 0, 0, 0, 60, 281, 1, 0, 0, 0, 62, 285, 1, 0, 0, 0, 64, 292, 1, 0, 0, 0, 66, 294, 1, 0, 0, 0, 68, 307, 1, 0, 0, 0, 70, 309, 1, 0, 0, 0, 72, 73, 3, 2, 1, 0, 73, 74, 5, 0, 0, 1, 74, 1, 1, 0, 0, 0, 75, 76, 6, 1, -1, 0, 76, 77, 3, 4, 2, 0, 77, 78, 3, 2, 1, 8, 78, 81, 1, 0, 0, 0, 79, 81, 3, 24, 12, 0, 80, 75, 1, 0, 0, 0, 80, 79, 1, 0, 0, 0, 81, 114, 1, 0, 0, 0, 82, 83, 10, 10, 0, 0, 83, 84, 3, 6, 3, 0, 84, 85, 3, 2, 1, 10, 85, 113, 1, 0, 0, 0, 86, 87, 10, 7, 0, 0, 87, 88, 3, 8, 4, 0, 88, 89, 3, 2, 1, 8, 89, 113, 1, 0, 0, 0, 90, 91, 10, 6, 0, 0, 91, 92, 3, 10, 5, 0, 92, 93, 3, 2, 1, 7, 93, 113, 1, 0, 0, 0, 94, 95, 10, 5, 0, 0, 95, 96, 3, 12, 6, 0, 96, 97, 3, 2, 1, 6, 97, 113, 1, 0, 0, 0, 98, 99, 10, 4, 0, 0, 99, 100, 3, 14, 7, 0, 100, 101, 3, 2, 1, 5, 101, 113, 1, 0, 0, 0, 102, 103, 10, 3, 0, 0, 103, 104, 3, 16, 8, 0, 104, 105, 3, 2, 1, 4, 105, 113, 1, 0, 0, 0, 106, 107, 10, 2, 0, 0, 107, 108, 3, 18, 9, 0, 108, 109, 3, 2, 1, 3, 109, 113, 1, 0, 0, 0, 110, 111, 10, 9, 0, 0, 111, 113, 3, 20, 10, 0, 112, 82, 1, 0, 0, 0, 112, 86, 1, 0, 0, 0, 112, 90, 1, 0, 0, 0, 112, 94, 1, 0, 0, 0, 112, 98, 1, 0, 0, 0, 112, 102, 1, 0, 0, 0, 112, 106, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 116, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 3, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 118, 7, 0, 0, 0, 118, 5, 1, 0, 0, 0, 119, 121, 5, 8, 0, 0, 120, 122, 3, 54, 27, 0, 121, 120, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 7, 1, 0, 0, 0, 123, 125, 7, 1, 0, 0, 124, 126, 3, 54, 27, 0, 125, 124, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 9, 1, 0, 0, 0, 127, 129, 7, 0, 0, 0, 128, 130, 3, 54, 27, 0, 129, 128, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 11, 1, 0, 0, 0, 131, 133, 7, 2, 0, 0, 132, 134, 5, 28, 0, 0, 133, 132, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0, 134, 136, 1, 0, 0, 0, 135, 137, 3, 54, 27, 0, 136, 135, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 13, 1, 0, 0, 0, 138, 140, 7, 3, 0, 0, 139, 141, 3, 54, 27, 0, 140, 139, 1, 0, 0, 0, 140, 141, 1, 0, 0, 0, 141, 15, 1, 0, 0, 0, 142, 144, 5, 10, 0, 0, 143, 145, 3, 54, 27, 0, 144, 143, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 17, 1, 0, 0, 0, 146, 148, 7, 4, 0, 0, 147, 149, 3, 54, 27, 0, 148, 147, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 19, 1, 0, 0, 0, 150, 152, 5, 38, 0, 0, 151, 153, 3, 22, 11, 0, 152, 151, 1, 0, 0, 0, 152, 153, 1, 0, 0, 0, 153, 21, 1, 0, 0, 0, 154, 155, 5, 27, 0, 0, 155, 156, 5, 40, 0, 0, 156, 23, 1, 0, 0, 0, 157, 165, 3, 40, 20, 0, 158, 165, 3, 46, 23, 0, 159, 165, 3, 28, 14, 0, 160, 165, 3, 36, 18, 0, 161, 165, 3, 38, 19, 0, 162, 165, 3, 70, 35, 0, 163, 165, 3, 26, 13, 0, 164, 157, 1, 0, 0, 0, 164, 158, 1, 0, 0, 0, 164, 159, 1, 0, 0, 0, 164, 160, 1, 0, 0, 0, 164, 161, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 163, 1, 0, 0, 0, 165, 25, 1, 0, 0, 0, 166, 167, 5, 33, 0, 0, 167, 168, 3, 2, 1, 0, 168, 169, 5, 34, 0, 0, 169, 27, 1, 0, 0, 0, 170, 176, 5, 41, 0, 0, 171, 173, 5, 31, 0, 0, 172, 174, 3, 34, 17, 0, 173, 172, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, 177, 5, 32, 0, 0, 176, 171, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 183, 1, 0, 0, 0, 178, 179, 5, 31, 0, 0, 179, 180, 3, 34, 17, 0, 180, 181, 5, 32, 0, 0, 181, 183, 1, 0, 0, 0, 182, 170, 1, 0, 0, 0, 182, 178, 1, 0, 0, 0, 183, 29, 1, 0, 0, 0, 184, 185, 3, 64, 32, 0, 185, 186, 3, 32, 16, 0, 186, 187, 5, 2, 0, 0, 187, 31, 1, 0, 0, 0, 188, 189, 7, 5, 0, 0, 189, 33, 1, 0, 0, 0, 190, 195, 3, 30, 15, 0, 191, 192, 5, 37, 0, 0, 192, 194, 3, 30, 15, 0, 193, 191, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 199, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 200, 5, 37, 0, 0, 199, 198, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 35, 1, 0, 0, 0, 201, 202, 3, 28, 14, 0, 202, 203, 5, 39, 0, 0, 203, 37, 1, 0, 0, 0, 204, 205, 3, 28, 14, 0, 205, 206, 5, 27, 0, 0, 206, 207, 5, 40, 0, 0, 207, 213, 1, 0, 0, 0, 208, 209, 3, 36, 18, 0, 209, 210, 5, 27, 0, 0, 210, 211, 5, 40, 0, 0, 211, 213, 1, 0, 0, 0, 212, 204, 1, 0, 0, 0, 212, 208, 1, 0, 0, 0, 213, 39, 1, 0, 0, 0, 214, 215, 5, 30, 0, 0, 215, 224, 5, 33, 0, 0, 216, 221, 3, 42, 21, 0, 217, 218, 5, 37, 0, 0, 218, 220, 3, 42, 21, 0, 219, 217, 1, 0, 0, 0, 220, 223, 1, 0, 0, 0, 221, 219, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 225, 1, 0, 0, 0, 223, 221, 1, 0, 0, 0, 224, 216, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 227, 5, 34, 0, 0, 227, 41, 1, 0, 0, 0, 228, 231, 3, 70, 35, 0, 229, 231, 3, 2, 1, 0, 230, 228, 1, 0, 0, 0, 230, 229, 1, 0, 0, 0, 231, 43, 1, 0, 0, 0, 232, 241, 5, 33, 0, 0, 233, 238, 3, 42, 21, 0, 234, 235, 5, 37, 0, 0, 235, 237, 3, 42, 21, 0, 236, 234, 1, 0, 0, 0, 237, 240, 1, 0, 0, 0, 238, 236, 1, 0, 0, 0, 238, 239, 1, 0, 0, 0, 239, 242, 1, 0, 0, 0, 240, 238, 1, 0, 0, 0, 241, 233, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 243, 1, 0, 0, 0, 243, 244, 5, 34, 0, 0, 244, 45, 1, 0, 0, 0, 245, 246, 5, 29, 0, 0, 246, 256, 3, 44, 22, 0, 247, 248, 5, 29, 0, 0, 248, 249, 3, 52, 26, 0, 249, 250, 3, 44, 22, 0, 250, 256, 1, 0, 0, 0, 251, 252, 5, 29, 0, 0, 252, 253, 3, 44, 22, 0, 253, 254, 3, 52, 26, 0, 254, 256, 1, 0, 0, 0, 255, 245, 1, 0, 0, 0, 255, 247, 1, 0, 0, 0, 255, 251, 1, 0, 0, 0, 256, 47, 1, 0, 0, 0, 257, 258, 5, 21, 0, 0, 258, 259, 3, 66, 33, 0, 259, 49, 1, 0, 0, 0, 260, 261, 5, 22, 0, 0, 261, 262, 3, 66, 33, 0, 262, 51, 1, 0, 0, 0, 263, 266, 3, 48, 24, 0, 264, 266, 3, 50, 25, 0, 265, 263, 1, 0, 0, 0, 265, 264, 1, 0, 0, 0, 266, 53, 1, 0, 0, 0, 267, 270, 3, 56, 28, 0, 268, 270, 3, 58, 29, 0, 269, 267, 1, 0, 0, 0, 269, 268, 1, 0, 0, 0, 270, 273, 1, 0, 0, 0, 271, 274, 3, 60, 30, 0, 272, 274, 3, 62, 31, 0, 273, 271, 1, 0, 0, 0, 273, 272, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 55, 1, 0, 0, 0, 275, 276, 5, 23, 0, 0, 276, 277, 3, 66, 33, 0, 277, 57, 1, 0, 0, 0, 278, 279, 5, 24, 0, 0, 279, 280, 3, 66, 33, 0, 280, 59, 1, 0, 0, 0, 281, 283, 5, 25, 0, 0, 282, 284, 3, 66, 33, 0, 283, 282, 1, 0, 0, 0, 283, 284, 1, 0, 0, 0, 284, 61, 1, 0, 0, 0, 285, 287, 5, 26, 0, 0, 286, 288, 3, 66, 33, 0, 287, 286, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 63, 1, 0, 0, 0, 289, 293, 3, 68, 34, 0, 290, 293, 5, 41, 0, 0, 291, 293, 5, 42, 0, 0, 292, 289, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 292, 291, 1, 0, 0, 0, 293, 65, 1, 0, 0, 0, 294, 303, 5, 33, 0, 0, 295, 300, 3, 64, 32, 0, 296, 297, 5, 37, 0, 0, 297, 299, 3, 64, 32, 0, 298, 296, 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, 0, 0, 301, 304, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 295, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 306, 5, 34, 0, 0, 306, 67, 1, 0, 0, 0, 307, 308, 7, 6, 0, 0, 308, 69, 1, 0, 0, 0, 309, 310, 7, 7, 0, 0, 310, 71, 1, 0, 0, 0, 33, 80, 112, 114, 121, 125, 129, 133, 136, 140, 144, 148, 152, 164, 173, 176, 182, 195, 199, 212, 221, 224, 230, 238, 241, 255, 265, 269, 273, 283, 287, 292, 300, 303] -------------------------------------------------------------------------------- /promformat/parser/PromQLParser.tokens: -------------------------------------------------------------------------------- 1 | NUMBER=1 2 | STRING=2 3 | ADD=3 4 | SUB=4 5 | MULT=5 6 | DIV=6 7 | MOD=7 8 | POW=8 9 | AND=9 10 | OR=10 11 | UNLESS=11 12 | EQ=12 13 | DEQ=13 14 | NE=14 15 | GT=15 16 | LT=16 17 | GE=17 18 | LE=18 19 | RE=19 20 | NRE=20 21 | BY=21 22 | WITHOUT=22 23 | ON=23 24 | IGNORING=24 25 | GROUP_LEFT=25 26 | GROUP_RIGHT=26 27 | OFFSET=27 28 | BOOL=28 29 | AGGREGATION_OPERATOR=29 30 | FUNCTION=30 31 | LEFT_BRACE=31 32 | RIGHT_BRACE=32 33 | LEFT_PAREN=33 34 | RIGHT_PAREN=34 35 | LEFT_BRACKET=35 36 | RIGHT_BRACKET=36 37 | COMMA=37 38 | SUBQUERY_RANGE=38 39 | TIME_RANGE=39 40 | DURATION=40 41 | METRIC_NAME=41 42 | LABEL_NAME=42 43 | WS=43 44 | SL_COMMENT=44 45 | '+'=3 46 | '-'=4 47 | '*'=5 48 | '/'=6 49 | '%'=7 50 | '^'=8 51 | 'and'=9 52 | 'or'=10 53 | 'unless'=11 54 | '='=12 55 | '=='=13 56 | '!='=14 57 | '>'=15 58 | '<'=16 59 | '>='=17 60 | '<='=18 61 | '=~'=19 62 | '!~'=20 63 | 'by'=21 64 | 'without'=22 65 | 'on'=23 66 | 'ignoring'=24 67 | 'group_left'=25 68 | 'group_right'=26 69 | 'offset'=27 70 | 'bool'=28 71 | '{'=31 72 | '}'=32 73 | '('=33 74 | ')'=34 75 | '['=35 76 | ']'=36 77 | ','=37 78 | -------------------------------------------------------------------------------- /promformat/parser/PromQLParserListener.py: -------------------------------------------------------------------------------- 1 | # Generated from PromQLParser.g4 by ANTLR 4.10 2 | from antlr4 import * 3 | 4 | if __name__ is not None and "." in __name__: 5 | from .PromQLParser import PromQLParser 6 | else: 7 | from PromQLParser import PromQLParser 8 | 9 | # This class defines a complete listener for a parse tree produced by PromQLParser. 10 | class PromQLParserListener(ParseTreeListener): 11 | 12 | # Enter a parse tree produced by PromQLParser#expression. 13 | def enterExpression(self, ctx: PromQLParser.ExpressionContext): 14 | pass 15 | 16 | # Exit a parse tree produced by PromQLParser#expression. 17 | def exitExpression(self, ctx: PromQLParser.ExpressionContext): 18 | pass 19 | 20 | # Enter a parse tree produced by PromQLParser#vectorOperation. 21 | def enterVectorOperation(self, ctx: PromQLParser.VectorOperationContext): 22 | pass 23 | 24 | # Exit a parse tree produced by PromQLParser#vectorOperation. 25 | def exitVectorOperation(self, ctx: PromQLParser.VectorOperationContext): 26 | pass 27 | 28 | # Enter a parse tree produced by PromQLParser#unaryOp. 29 | def enterUnaryOp(self, ctx: PromQLParser.UnaryOpContext): 30 | pass 31 | 32 | # Exit a parse tree produced by PromQLParser#unaryOp. 33 | def exitUnaryOp(self, ctx: PromQLParser.UnaryOpContext): 34 | pass 35 | 36 | # Enter a parse tree produced by PromQLParser#powOp. 37 | def enterPowOp(self, ctx: PromQLParser.PowOpContext): 38 | pass 39 | 40 | # Exit a parse tree produced by PromQLParser#powOp. 41 | def exitPowOp(self, ctx: PromQLParser.PowOpContext): 42 | pass 43 | 44 | # Enter a parse tree produced by PromQLParser#multOp. 45 | def enterMultOp(self, ctx: PromQLParser.MultOpContext): 46 | pass 47 | 48 | # Exit a parse tree produced by PromQLParser#multOp. 49 | def exitMultOp(self, ctx: PromQLParser.MultOpContext): 50 | pass 51 | 52 | # Enter a parse tree produced by PromQLParser#addOp. 53 | def enterAddOp(self, ctx: PromQLParser.AddOpContext): 54 | pass 55 | 56 | # Exit a parse tree produced by PromQLParser#addOp. 57 | def exitAddOp(self, ctx: PromQLParser.AddOpContext): 58 | pass 59 | 60 | # Enter a parse tree produced by PromQLParser#compareOp. 61 | def enterCompareOp(self, ctx: PromQLParser.CompareOpContext): 62 | pass 63 | 64 | # Exit a parse tree produced by PromQLParser#compareOp. 65 | def exitCompareOp(self, ctx: PromQLParser.CompareOpContext): 66 | pass 67 | 68 | # Enter a parse tree produced by PromQLParser#andUnlessOp. 69 | def enterAndUnlessOp(self, ctx: PromQLParser.AndUnlessOpContext): 70 | pass 71 | 72 | # Exit a parse tree produced by PromQLParser#andUnlessOp. 73 | def exitAndUnlessOp(self, ctx: PromQLParser.AndUnlessOpContext): 74 | pass 75 | 76 | # Enter a parse tree produced by PromQLParser#orOp. 77 | def enterOrOp(self, ctx: PromQLParser.OrOpContext): 78 | pass 79 | 80 | # Exit a parse tree produced by PromQLParser#orOp. 81 | def exitOrOp(self, ctx: PromQLParser.OrOpContext): 82 | pass 83 | 84 | # Enter a parse tree produced by PromQLParser#vectorMatchOp. 85 | def enterVectorMatchOp(self, ctx: PromQLParser.VectorMatchOpContext): 86 | pass 87 | 88 | # Exit a parse tree produced by PromQLParser#vectorMatchOp. 89 | def exitVectorMatchOp(self, ctx: PromQLParser.VectorMatchOpContext): 90 | pass 91 | 92 | # Enter a parse tree produced by PromQLParser#subqueryOp. 93 | def enterSubqueryOp(self, ctx: PromQLParser.SubqueryOpContext): 94 | pass 95 | 96 | # Exit a parse tree produced by PromQLParser#subqueryOp. 97 | def exitSubqueryOp(self, ctx: PromQLParser.SubqueryOpContext): 98 | pass 99 | 100 | # Enter a parse tree produced by PromQLParser#offsetOp. 101 | def enterOffsetOp(self, ctx: PromQLParser.OffsetOpContext): 102 | pass 103 | 104 | # Exit a parse tree produced by PromQLParser#offsetOp. 105 | def exitOffsetOp(self, ctx: PromQLParser.OffsetOpContext): 106 | pass 107 | 108 | # Enter a parse tree produced by PromQLParser#vector. 109 | def enterVector(self, ctx: PromQLParser.VectorContext): 110 | pass 111 | 112 | # Exit a parse tree produced by PromQLParser#vector. 113 | def exitVector(self, ctx: PromQLParser.VectorContext): 114 | pass 115 | 116 | # Enter a parse tree produced by PromQLParser#parens. 117 | def enterParens(self, ctx: PromQLParser.ParensContext): 118 | pass 119 | 120 | # Exit a parse tree produced by PromQLParser#parens. 121 | def exitParens(self, ctx: PromQLParser.ParensContext): 122 | pass 123 | 124 | # Enter a parse tree produced by PromQLParser#instantSelector. 125 | def enterInstantSelector(self, ctx: PromQLParser.InstantSelectorContext): 126 | pass 127 | 128 | # Exit a parse tree produced by PromQLParser#instantSelector. 129 | def exitInstantSelector(self, ctx: PromQLParser.InstantSelectorContext): 130 | pass 131 | 132 | # Enter a parse tree produced by PromQLParser#labelMatcher. 133 | def enterLabelMatcher(self, ctx: PromQLParser.LabelMatcherContext): 134 | pass 135 | 136 | # Exit a parse tree produced by PromQLParser#labelMatcher. 137 | def exitLabelMatcher(self, ctx: PromQLParser.LabelMatcherContext): 138 | pass 139 | 140 | # Enter a parse tree produced by PromQLParser#labelMatcherOperator. 141 | def enterLabelMatcherOperator(self, ctx: PromQLParser.LabelMatcherOperatorContext): 142 | pass 143 | 144 | # Exit a parse tree produced by PromQLParser#labelMatcherOperator. 145 | def exitLabelMatcherOperator(self, ctx: PromQLParser.LabelMatcherOperatorContext): 146 | pass 147 | 148 | # Enter a parse tree produced by PromQLParser#labelMatcherList. 149 | def enterLabelMatcherList(self, ctx: PromQLParser.LabelMatcherListContext): 150 | pass 151 | 152 | # Exit a parse tree produced by PromQLParser#labelMatcherList. 153 | def exitLabelMatcherList(self, ctx: PromQLParser.LabelMatcherListContext): 154 | pass 155 | 156 | # Enter a parse tree produced by PromQLParser#matrixSelector. 157 | def enterMatrixSelector(self, ctx: PromQLParser.MatrixSelectorContext): 158 | pass 159 | 160 | # Exit a parse tree produced by PromQLParser#matrixSelector. 161 | def exitMatrixSelector(self, ctx: PromQLParser.MatrixSelectorContext): 162 | pass 163 | 164 | # Enter a parse tree produced by PromQLParser#offset. 165 | def enterOffset(self, ctx: PromQLParser.OffsetContext): 166 | pass 167 | 168 | # Exit a parse tree produced by PromQLParser#offset. 169 | def exitOffset(self, ctx: PromQLParser.OffsetContext): 170 | pass 171 | 172 | # Enter a parse tree produced by PromQLParser#function_. 173 | def enterFunction_(self, ctx: PromQLParser.Function_Context): 174 | pass 175 | 176 | # Exit a parse tree produced by PromQLParser#function_. 177 | def exitFunction_(self, ctx: PromQLParser.Function_Context): 178 | pass 179 | 180 | # Enter a parse tree produced by PromQLParser#parameter. 181 | def enterParameter(self, ctx: PromQLParser.ParameterContext): 182 | pass 183 | 184 | # Exit a parse tree produced by PromQLParser#parameter. 185 | def exitParameter(self, ctx: PromQLParser.ParameterContext): 186 | pass 187 | 188 | # Enter a parse tree produced by PromQLParser#parameterList. 189 | def enterParameterList(self, ctx: PromQLParser.ParameterListContext): 190 | pass 191 | 192 | # Exit a parse tree produced by PromQLParser#parameterList. 193 | def exitParameterList(self, ctx: PromQLParser.ParameterListContext): 194 | pass 195 | 196 | # Enter a parse tree produced by PromQLParser#aggregation. 197 | def enterAggregation(self, ctx: PromQLParser.AggregationContext): 198 | pass 199 | 200 | # Exit a parse tree produced by PromQLParser#aggregation. 201 | def exitAggregation(self, ctx: PromQLParser.AggregationContext): 202 | pass 203 | 204 | # Enter a parse tree produced by PromQLParser#by. 205 | def enterBy(self, ctx: PromQLParser.ByContext): 206 | pass 207 | 208 | # Exit a parse tree produced by PromQLParser#by. 209 | def exitBy(self, ctx: PromQLParser.ByContext): 210 | pass 211 | 212 | # Enter a parse tree produced by PromQLParser#without. 213 | def enterWithout(self, ctx: PromQLParser.WithoutContext): 214 | pass 215 | 216 | # Exit a parse tree produced by PromQLParser#without. 217 | def exitWithout(self, ctx: PromQLParser.WithoutContext): 218 | pass 219 | 220 | # Enter a parse tree produced by PromQLParser#byWithout. 221 | def enterByWithout(self, ctx: PromQLParser.ByWithoutContext): 222 | pass 223 | 224 | # Exit a parse tree produced by PromQLParser#byWithout. 225 | def exitByWithout(self, ctx: PromQLParser.ByWithoutContext): 226 | pass 227 | 228 | # Enter a parse tree produced by PromQLParser#grouping. 229 | def enterGrouping(self, ctx: PromQLParser.GroupingContext): 230 | pass 231 | 232 | # Exit a parse tree produced by PromQLParser#grouping. 233 | def exitGrouping(self, ctx: PromQLParser.GroupingContext): 234 | pass 235 | 236 | # Enter a parse tree produced by PromQLParser#on_. 237 | def enterOn_(self, ctx: PromQLParser.On_Context): 238 | pass 239 | 240 | # Exit a parse tree produced by PromQLParser#on_. 241 | def exitOn_(self, ctx: PromQLParser.On_Context): 242 | pass 243 | 244 | # Enter a parse tree produced by PromQLParser#ignoring. 245 | def enterIgnoring(self, ctx: PromQLParser.IgnoringContext): 246 | pass 247 | 248 | # Exit a parse tree produced by PromQLParser#ignoring. 249 | def exitIgnoring(self, ctx: PromQLParser.IgnoringContext): 250 | pass 251 | 252 | # Enter a parse tree produced by PromQLParser#groupLeft. 253 | def enterGroupLeft(self, ctx: PromQLParser.GroupLeftContext): 254 | pass 255 | 256 | # Exit a parse tree produced by PromQLParser#groupLeft. 257 | def exitGroupLeft(self, ctx: PromQLParser.GroupLeftContext): 258 | pass 259 | 260 | # Enter a parse tree produced by PromQLParser#groupRight. 261 | def enterGroupRight(self, ctx: PromQLParser.GroupRightContext): 262 | pass 263 | 264 | # Exit a parse tree produced by PromQLParser#groupRight. 265 | def exitGroupRight(self, ctx: PromQLParser.GroupRightContext): 266 | pass 267 | 268 | # Enter a parse tree produced by PromQLParser#labelName. 269 | def enterLabelName(self, ctx: PromQLParser.LabelNameContext): 270 | pass 271 | 272 | # Exit a parse tree produced by PromQLParser#labelName. 273 | def exitLabelName(self, ctx: PromQLParser.LabelNameContext): 274 | pass 275 | 276 | # Enter a parse tree produced by PromQLParser#labelNameList. 277 | def enterLabelNameList(self, ctx: PromQLParser.LabelNameListContext): 278 | pass 279 | 280 | # Exit a parse tree produced by PromQLParser#labelNameList. 281 | def exitLabelNameList(self, ctx: PromQLParser.LabelNameListContext): 282 | pass 283 | 284 | # Enter a parse tree produced by PromQLParser#keyword. 285 | def enterKeyword(self, ctx: PromQLParser.KeywordContext): 286 | pass 287 | 288 | # Exit a parse tree produced by PromQLParser#keyword. 289 | def exitKeyword(self, ctx: PromQLParser.KeywordContext): 290 | pass 291 | 292 | # Enter a parse tree produced by PromQLParser#literal. 293 | def enterLiteral(self, ctx: PromQLParser.LiteralContext): 294 | pass 295 | 296 | # Exit a parse tree produced by PromQLParser#literal. 297 | def exitLiteral(self, ctx: PromQLParser.LiteralContext): 298 | pass 299 | 300 | 301 | del PromQLParser 302 | -------------------------------------------------------------------------------- /promformat/parser/PromQLParserVisitor.py: -------------------------------------------------------------------------------- 1 | # Generated from PromQLParser.g4 by ANTLR 4.10 2 | from antlr4 import * 3 | 4 | if __name__ is not None and "." in __name__: 5 | from .PromQLParser import PromQLParser 6 | else: 7 | from PromQLParser import PromQLParser 8 | 9 | # This class defines a complete generic visitor for a parse tree produced by PromQLParser. 10 | 11 | 12 | class PromQLParserVisitor(ParseTreeVisitor): 13 | 14 | # Visit a parse tree produced by PromQLParser#expression. 15 | def visitExpression(self, ctx: PromQLParser.ExpressionContext): 16 | return self.visitChildren(ctx) 17 | 18 | # Visit a parse tree produced by PromQLParser#vectorOperation. 19 | def visitVectorOperation(self, ctx: PromQLParser.VectorOperationContext): 20 | return self.visitChildren(ctx) 21 | 22 | # Visit a parse tree produced by PromQLParser#unaryOp. 23 | def visitUnaryOp(self, ctx: PromQLParser.UnaryOpContext): 24 | return self.visitChildren(ctx) 25 | 26 | # Visit a parse tree produced by PromQLParser#powOp. 27 | def visitPowOp(self, ctx: PromQLParser.PowOpContext): 28 | return self.visitChildren(ctx) 29 | 30 | # Visit a parse tree produced by PromQLParser#multOp. 31 | def visitMultOp(self, ctx: PromQLParser.MultOpContext): 32 | return self.visitChildren(ctx) 33 | 34 | # Visit a parse tree produced by PromQLParser#addOp. 35 | def visitAddOp(self, ctx: PromQLParser.AddOpContext): 36 | return self.visitChildren(ctx) 37 | 38 | # Visit a parse tree produced by PromQLParser#compareOp. 39 | def visitCompareOp(self, ctx: PromQLParser.CompareOpContext): 40 | return self.visitChildren(ctx) 41 | 42 | # Visit a parse tree produced by PromQLParser#andUnlessOp. 43 | def visitAndUnlessOp(self, ctx: PromQLParser.AndUnlessOpContext): 44 | return self.visitChildren(ctx) 45 | 46 | # Visit a parse tree produced by PromQLParser#orOp. 47 | def visitOrOp(self, ctx: PromQLParser.OrOpContext): 48 | return self.visitChildren(ctx) 49 | 50 | # Visit a parse tree produced by PromQLParser#vectorMatchOp. 51 | def visitVectorMatchOp(self, ctx: PromQLParser.VectorMatchOpContext): 52 | return self.visitChildren(ctx) 53 | 54 | # Visit a parse tree produced by PromQLParser#subqueryOp. 55 | def visitSubqueryOp(self, ctx: PromQLParser.SubqueryOpContext): 56 | return self.visitChildren(ctx) 57 | 58 | # Visit a parse tree produced by PromQLParser#offsetOp. 59 | def visitOffsetOp(self, ctx: PromQLParser.OffsetOpContext): 60 | return self.visitChildren(ctx) 61 | 62 | # Visit a parse tree produced by PromQLParser#vector. 63 | def visitVector(self, ctx: PromQLParser.VectorContext): 64 | return self.visitChildren(ctx) 65 | 66 | # Visit a parse tree produced by PromQLParser#parens. 67 | def visitParens(self, ctx: PromQLParser.ParensContext): 68 | return self.visitChildren(ctx) 69 | 70 | # Visit a parse tree produced by PromQLParser#instantSelector. 71 | def visitInstantSelector(self, ctx: PromQLParser.InstantSelectorContext): 72 | return self.visitChildren(ctx) 73 | 74 | # Visit a parse tree produced by PromQLParser#labelMatcher. 75 | def visitLabelMatcher(self, ctx: PromQLParser.LabelMatcherContext): 76 | return self.visitChildren(ctx) 77 | 78 | # Visit a parse tree produced by PromQLParser#labelMatcherOperator. 79 | def visitLabelMatcherOperator(self, ctx: PromQLParser.LabelMatcherOperatorContext): 80 | return self.visitChildren(ctx) 81 | 82 | # Visit a parse tree produced by PromQLParser#labelMatcherList. 83 | def visitLabelMatcherList(self, ctx: PromQLParser.LabelMatcherListContext): 84 | return self.visitChildren(ctx) 85 | 86 | # Visit a parse tree produced by PromQLParser#matrixSelector. 87 | def visitMatrixSelector(self, ctx: PromQLParser.MatrixSelectorContext): 88 | return self.visitChildren(ctx) 89 | 90 | # Visit a parse tree produced by PromQLParser#offset. 91 | def visitOffset(self, ctx: PromQLParser.OffsetContext): 92 | return self.visitChildren(ctx) 93 | 94 | # Visit a parse tree produced by PromQLParser#function_. 95 | def visitFunction_(self, ctx: PromQLParser.Function_Context): 96 | return self.visitChildren(ctx) 97 | 98 | # Visit a parse tree produced by PromQLParser#parameter. 99 | def visitParameter(self, ctx: PromQLParser.ParameterContext): 100 | return self.visitChildren(ctx) 101 | 102 | # Visit a parse tree produced by PromQLParser#parameterList. 103 | def visitParameterList(self, ctx: PromQLParser.ParameterListContext): 104 | return self.visitChildren(ctx) 105 | 106 | # Visit a parse tree produced by PromQLParser#aggregation. 107 | def visitAggregation(self, ctx: PromQLParser.AggregationContext): 108 | return self.visitChildren(ctx) 109 | 110 | # Visit a parse tree produced by PromQLParser#by. 111 | def visitBy(self, ctx: PromQLParser.ByContext): 112 | return self.visitChildren(ctx) 113 | 114 | # Visit a parse tree produced by PromQLParser#without. 115 | def visitWithout(self, ctx: PromQLParser.WithoutContext): 116 | return self.visitChildren(ctx) 117 | 118 | # Visit a parse tree produced by PromQLParser#byWithout. 119 | def visitByWithout(self, ctx: PromQLParser.ByWithoutContext): 120 | return self.visitChildren(ctx) 121 | 122 | # Visit a parse tree produced by PromQLParser#grouping. 123 | def visitGrouping(self, ctx: PromQLParser.GroupingContext): 124 | return self.visitChildren(ctx) 125 | 126 | # Visit a parse tree produced by PromQLParser#on_. 127 | def visitOn_(self, ctx: PromQLParser.On_Context): 128 | return self.visitChildren(ctx) 129 | 130 | # Visit a parse tree produced by PromQLParser#ignoring. 131 | def visitIgnoring(self, ctx: PromQLParser.IgnoringContext): 132 | return self.visitChildren(ctx) 133 | 134 | # Visit a parse tree produced by PromQLParser#groupLeft. 135 | def visitGroupLeft(self, ctx: PromQLParser.GroupLeftContext): 136 | return self.visitChildren(ctx) 137 | 138 | # Visit a parse tree produced by PromQLParser#groupRight. 139 | def visitGroupRight(self, ctx: PromQLParser.GroupRightContext): 140 | return self.visitChildren(ctx) 141 | 142 | # Visit a parse tree produced by PromQLParser#labelName. 143 | def visitLabelName(self, ctx: PromQLParser.LabelNameContext): 144 | return self.visitChildren(ctx) 145 | 146 | # Visit a parse tree produced by PromQLParser#labelNameList. 147 | def visitLabelNameList(self, ctx: PromQLParser.LabelNameListContext): 148 | return self.visitChildren(ctx) 149 | 150 | # Visit a parse tree produced by PromQLParser#keyword. 151 | def visitKeyword(self, ctx: PromQLParser.KeywordContext): 152 | return self.visitChildren(ctx) 153 | 154 | # Visit a parse tree produced by PromQLParser#literal. 155 | def visitLiteral(self, ctx: PromQLParser.LiteralContext): 156 | return self.visitChildren(ctx) 157 | 158 | 159 | del PromQLParser 160 | -------------------------------------------------------------------------------- /promformat/parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facetoe/promformat/bb0fb08dd60ad06796e0ce058d157e0b6f0f3d95/promformat/parser/__init__.py -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name="promformat", 5 | version="1.0.2", 6 | packages=find_packages(exclude=["tests*"]), 7 | install_requires=["antlr4-python3-runtime>=4.10"], 8 | tests_require=["pytest", "PyYAML"], 9 | setup_requires=["flake8", "black"], 10 | entry_points={ 11 | "console_scripts": [ 12 | "promformat = promformat.__main__:main", 13 | ], 14 | }, 15 | ) 16 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facetoe/promformat/bb0fb08dd60ad06796e0ce058d157e0b6f0f3d95/tests/__init__.py -------------------------------------------------------------------------------- /tests/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facetoe/promformat/bb0fb08dd60ad06796e0ce058d157e0b6f0f3d95/tests/resources/__init__.py -------------------------------------------------------------------------------- /tests/resources/formatted/00992daead1333589551e2c702cb583d: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | istio_requests_total 6 | { 7 | reporter="destination" 8 | } [5m] 9 | ) 10 | ) > 1000 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/00ff2c1629e21834cf03a43ca0266763: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | istio_requests_total 6 | { 7 | reporter="destination" 8 | } [5m] 9 | ) 10 | ) < 100 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/01c5ed5def7d1bc5d1db969aaab1949a: -------------------------------------------------------------------------------- 1 | mysql_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/0241aea91b6a92c6343e7f0a1fed5610: -------------------------------------------------------------------------------- 1 | ( 2 | 1 - ( 3 | node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes 4 | ) 5 | ) * 100 > 80 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/02db4cafaf59e43715109eca280bbf18: -------------------------------------------------------------------------------- 1 | mongodb_replset_member_state == 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/038b224f783314c387cbfcd31e21acb3: -------------------------------------------------------------------------------- 1 | ssl_ocsp_response_status == 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/043c7280da7d6e4a95d14d828eeb92b2: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | redis_connected_slaves [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/047aab58010d14e9b4e08eda3aa02862: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | elasticsearch_indices_docs 4 | { 5 | es_data_node="true" 6 | } [10m] 7 | ) < 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/0484b128ae0ef3bfe4bf4fe400c369b3: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | datname 4 | ) 5 | ( 6 | pg_stat_activity_count 7 | { 8 | datname!~"template.*|postgres" 9 | } 10 | ) < 5 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/0496da0631b0e8e4c8200a1f582b90c5: -------------------------------------------------------------------------------- 1 | haproxy_backend_active_servers + haproxy_backend_backup_servers == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/04bb59d9823b25195fb41b45a7e24d1b: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | mysql_global_status_slow_queries [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/053b7e540b1890cef3ec7d55ba8f727d: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_unassigned_shards > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/06621b9b60933e0fc906a897b796359e: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:connection:totaltimeouts:count" 6 | } [1m] 7 | ) > 5 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/06750f0ccb028acfb7d300abdffbd16b: -------------------------------------------------------------------------------- 1 | ( 2 | node_bonding_active - node_bonding_slaves 3 | ) != 0 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/0683afa7bdfef12041d0bd1e432dca12: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | traefik_service_requests_total 6 | { 7 | code=~"5.*" 8 | } [3m] 9 | ) 10 | ) 11 | by 12 | ( 13 | service 14 | ) / sum 15 | ( 16 | rate 17 | ( 18 | traefik_service_requests_total [3m] 19 | ) 20 | ) 21 | by 22 | ( 23 | service 24 | ) * 100 > 5 25 | -------------------------------------------------------------------------------- /tests/resources/formatted/06f166ed3b43fff5a0e9193347ebe5ad: -------------------------------------------------------------------------------- 1 | default_jenkins_builds_last_build_tests_failing > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/074327596df2f7e998c1f1daf49fa955: -------------------------------------------------------------------------------- 1 | node_systemd_unit_state 2 | { 3 | state="failed" 4 | } == 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/078f7ce131e780d087612f60db549212: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | backend 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_backend_retry_warnings_total [1m] 9 | ) 10 | ) > 10 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/08580b2bc21e75bbcb70ff77e65a0ddd: -------------------------------------------------------------------------------- 1 | ( 2 | time 3 | ( 4 | ) - thanos_objstore_bucket_last_successful_upload_time 5 | ) > 24 * 60 * 60 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/0869b90054562b7a571a932f3ad665fd: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_number_of_pending_tasks > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/08a226e383c2250387a370931cfbb13d: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | zk_server_leader 4 | ) == 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/08dfe49ee5fcbf510731e6cf2c5bba7d: -------------------------------------------------------------------------------- 1 | etcd_server_has_leader == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/09f49b27d067909a24b45ee91a0a7418: -------------------------------------------------------------------------------- 1 | node_edac_uncorrectable_errors_total > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/0a2f212f22cc3211cd3c927521b47bc6: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | traefik_backend_server_up 4 | ) 5 | by 6 | ( 7 | backend 8 | ) == 0 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/0aaba81532e0cda8a7ec0f901e0389c1: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | postgresql_errors_total 4 | { 5 | type="statement_timeout" 6 | } [1m] 7 | ) > 3 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/0b796afc52a94801512bc493283f2ba7: -------------------------------------------------------------------------------- 1 | 100 * sum 2 | ( 3 | rate 4 | ( 5 | promtail_request_duration_seconds_count 6 | { 7 | status_code=~"5..|failed" 8 | } [1m] 9 | ) 10 | ) 11 | by 12 | ( 13 | namespace, 14 | job, 15 | route, 16 | instance 17 | ) / sum 18 | ( 19 | rate 20 | ( 21 | promtail_request_duration_seconds_count [1m] 22 | ) 23 | ) 24 | by 25 | ( 26 | namespace, 27 | job, 28 | route, 29 | instance 30 | ) > 10 31 | -------------------------------------------------------------------------------- /tests/resources/formatted/0baea55faa2cdb786e5c5b24b3a7a8ca: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | bookie_SERVER_STATUS 4 | { 5 | } == 0 6 | ) 7 | by 8 | ( 9 | pod 10 | ) 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/0ca9626022ca1ed2f098301d7a64ed83: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:compaction:pendingtasks:value" 6 | } [1m] 7 | ) > 100 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/0ca969420398567379630625489ac0cc: -------------------------------------------------------------------------------- 1 | absent 2 | ( 3 | up 4 | { 5 | job="alertmanager" 6 | } 7 | ) 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/0d0007fe01eb88384d0ae329e16fcf39: -------------------------------------------------------------------------------- 1 | ceph_osd_weight < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/0d78ef575b9937a4222b9887e265d4df: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | cassandra_client_request_failures_total 4 | { 5 | operation="read" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/0de4ca80a6d09176d3972dbae80a5816: -------------------------------------------------------------------------------- 1 | consul_health_node_status 2 | { 3 | status="critical" 4 | } == 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/0e2326fffa446af244a937f9630e562d: -------------------------------------------------------------------------------- 1 | mysql_global_status_uptime < 60 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/0ef8cdb32570e82551971243ecbc308c: -------------------------------------------------------------------------------- 1 | cortex_ruler_config_last_reload_successful != 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/10039edb33bdf3e22b4063402eb743be: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | pulsar_sink_sink_exceptions_total 6 | { 7 | } [1m] 8 | ) > 10 9 | ) 10 | by 11 | ( 12 | name 13 | ) 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/100459494810732b1b97ab5446a1c307: -------------------------------------------------------------------------------- 1 | kube_node_status_condition 2 | { 3 | condition="Ready", 4 | status="true" 5 | } == 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/10fb62c9c8fc7eb829483b4cd36882c6: -------------------------------------------------------------------------------- 1 | delta 2 | ( 3 | kafka_burrow_partition_current_offset [1m] 4 | ) < 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/127c754b60ab5c88fadea4890488814a: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | rate 5 | ( 6 | etcd_disk_wal_fsync_duration_seconds_bucket [1m] 7 | ) 8 | ) > 0.5 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/12c2ffb1a0fb3d5164a8fbbf0293ef02: -------------------------------------------------------------------------------- 1 | apache_uptime_seconds_total / 60 < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/14e4e8c8ff63699650da3364eaf94355: -------------------------------------------------------------------------------- 1 | avg 2 | ( 3 | cassandra_table_tombstones_scanned 4 | { 5 | quantile="0.99" 6 | } 7 | ) 8 | by 9 | ( 10 | instance, 11 | cassandra_cluster, 12 | keyspace 13 | ) > 100 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/14e6e062b5aa8312dfa1fa51b08c6997: -------------------------------------------------------------------------------- 1 | pg_replication_lag > 30 and ON 2 | ( 3 | instance 4 | ) 5 | pg_replication_is_replica == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/15d6c11dbb647627dd3b15601e127802: -------------------------------------------------------------------------------- 1 | node_nf_conntrack_entries / node_nf_conntrack_entries_limit > 0.8 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/15eced1d51bd4c6adc01e8225e0b7cdb: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | haproxy_server_check_failures_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/1663f41ff1bf15a2bf431c74799882dc: -------------------------------------------------------------------------------- 1 | ssl_verified_cert_not_after 2 | { 3 | chain_no="0" 4 | } - time 5 | ( 6 | ) < 86400 * 7 7 | -------------------------------------------------------------------------------- /tests/resources/formatted/16a7a77d7e5998d3eda1e902811a1f6a: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | traefik_backend_requests_total 6 | { 7 | code=~"5.*" 8 | } [3m] 9 | ) 10 | ) 11 | by 12 | ( 13 | backend 14 | ) / sum 15 | ( 16 | rate 17 | ( 18 | traefik_backend_requests_total [3m] 19 | ) 20 | ) 21 | by 22 | ( 23 | backend 24 | ) * 100 > 5 25 | -------------------------------------------------------------------------------- /tests/resources/formatted/179b99cfb83afb3a9a7cf8680c1d19e1: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | kube_pod_container_status_restarts_total [1m] 4 | ) > 3 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/18439ae9c6aedc7e3ea735ef0b1a7aba: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | mysql_global_status_innodb_log_waits [15m] 4 | ) > 10 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/187b5984888e0d714d181529c305a4cf: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | mongodb_mongod_metrics_cursor_timed_out_total [1m] 4 | ) > 100 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/1aae9d86ccd81a4edd9741f62971828b: -------------------------------------------------------------------------------- 1 | ceph_monitor_avail_percent < 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/1bad85060ec7f660717c2ca3d2569aed: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_template_text_expansion_failures_total [3m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/1ce7859219038f31542b05549a879d8e: -------------------------------------------------------------------------------- 1 | time 2 | ( 3 | ) - container_last_seen > 60 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/1d1d808b2333c06fddb3609b33f4b266: -------------------------------------------------------------------------------- 1 | ( 2 | freeswitch_session_active * 100 / freeswitch_session_limit 3 | ) > 90 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/1d31cc16283784f40ac854370c31eae7: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | traefik_service_server_up 4 | ) 5 | by 6 | ( 7 | service 8 | ) == 0 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/1d749538e497451f2b338809dd2d574b: -------------------------------------------------------------------------------- 1 | zk_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/1dd6c030ed37a8409ec32df3d96d1c90: -------------------------------------------------------------------------------- 1 | probe_ssl_earliest_cert_expiry - time 2 | ( 3 | ) < 86400 * 30 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/2175364057816e0787f2e2ab35d9e147: -------------------------------------------------------------------------------- 1 | mysql_slave_status_master_server_id > 0 and ON 2 | ( 3 | instance 4 | ) 5 | mysql_slave_status_slave_io_running == 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/218b6e28bd5fe73566742a49b5a41776: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | redis_rejected_connections_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/219dae2934e4bbce22464e86aac12401: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:clientrequest:write:failures:oneminuterate" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/22149109d5523dcc21de9c670395a05d: -------------------------------------------------------------------------------- 1 | 100 - ( 2 | avg by 3 | ( 4 | instance 5 | ) 6 | ( 7 | rate 8 | ( 9 | windows_cpu_time_total 10 | { 11 | mode="idle" 12 | } [2m] 13 | ) 14 | ) * 100 15 | ) > 80 16 | -------------------------------------------------------------------------------- /tests/resources/formatted/22580c3a43d956b13b243e7a4e3d6f7b: -------------------------------------------------------------------------------- 1 | kube_statefulset_status_observed_generation != kube_statefulset_metadata_generation 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/22c8b9cccc9de20f97b390ded1f4e11b: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | etcd_http_failed_total [1m] 6 | ) 7 | ) 8 | BY 9 | ( 10 | method 11 | ) / sum 12 | ( 13 | rate 14 | ( 15 | etcd_http_received_total [1m] 16 | ) 17 | ) 18 | BY 19 | ( 20 | method 21 | ) > 0.01 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/22fa225f86a7c5a480c8539edd73ecf1: -------------------------------------------------------------------------------- 1 | consul_raft_peers < 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/23543ac00f69c154f8bcde48d32551ce: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_relocating_shards > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/238f5bb318b38e0ef92b93900b83379b: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_checkpoint_deletions_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/2557f48dc46a64040fe7b22c53588613: -------------------------------------------------------------------------------- 1 | kube_horizontalpodautoscaler_status_condition 2 | { 3 | status="false", 4 | condition="AbleToScale" 5 | } == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/2597f94df7ef269a4f841d56044d46f0: -------------------------------------------------------------------------------- 1 | max_over_time 2 | ( 3 | mysql_global_status_threads_connected [1m] 4 | ) / mysql_global_variables_max_connections * 100 > 80 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/2673d4ef2b7ace382a333441e7c868b7: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum by 4 | ( 5 | server 6 | ) 7 | ( 8 | rate 9 | ( 10 | haproxy_server_http_responses_total 11 | { 12 | code="5xx" 13 | } [1m] 14 | ) 15 | ) / sum by 16 | ( 17 | server 18 | ) 19 | ( 20 | rate 21 | ( 22 | haproxy_server_http_responses_total [1m] 23 | ) 24 | ) 25 | ) * 100 26 | ) > 5 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/278e3336392144a07e3dfe302949d49d: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:cache:keycache:hitrate:value" 4 | } < 85 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/280d2da9d088279fc39900a1e6c0cd61: -------------------------------------------------------------------------------- 1 | pg_bloat_table_bloat_pct > 80 and on 2 | ( 3 | relname 4 | ) 5 | ( 6 | pg_bloat_table_real_size > 200000000 7 | ) 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/29daba2cf53bb7f2c917326a78b6c385: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | node_disk_read_time_seconds_total [1m] 4 | ) / rate 5 | ( 6 | node_disk_reads_completed_total [1m] 7 | ) > 0.1 and rate 8 | ( 9 | node_disk_reads_completed_total [1m] 10 | ) > 0 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/2a059cdc137a9fef270946ae3e3b8fac: -------------------------------------------------------------------------------- 1 | kube_node_status_condition 2 | { 3 | condition="OutOfDisk", 4 | status="true" 5 | } == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/2a0afbbfbe27a4a4174f5e0024bf3bfb: -------------------------------------------------------------------------------- 1 | 2 | { 3 | __name__=~"pg_settings_.*" 4 | } != ON 5 | ( 6 | __name__ 7 | ) 8 | 9 | { 10 | __name__=~"pg_settings_([^t]|t[^r]|tr[^a]|tra[^n]|tran[^s]|trans[^a]|transa[^c]|transac[^t]|transact[^i]|transacti[^o]|transactio[^n]|transaction[^_]|transaction_[^r]|transaction_r[^e]|transaction_re[^a]|transaction_rea[^d]|transaction_read[^_]|transaction_read_[^o]|transaction_read_o[^n]|transaction_read_on[^l]|transaction_read_onl[^y]).*" 11 | } 12 | OFFSET 5m 13 | -------------------------------------------------------------------------------- /tests/resources/formatted/2a18b091f9b2e8d2cc59febea2af8c05: -------------------------------------------------------------------------------- 1 | avg by 2 | ( 3 | backend 4 | ) 5 | ( 6 | haproxy_backend_http_total_time_average_seconds 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/2a79df2a227783b07c15acc3be464360: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | pgbouncer_errors_count 4 | { 5 | errmsg!="server conn crashed?" 6 | } [1m] 7 | ) > 10 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/2a7e5f9a95cf3c4b7748085c48a031d6: -------------------------------------------------------------------------------- 1 | max 2 | ( 3 | sidekiq_queue_latency 4 | ) > 60 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/2bb024abfabe4fce5cb1425e89f9ce74: -------------------------------------------------------------------------------- 1 | junos_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/2c13a6b8c7d3a807a646b4cd2c8cfe12: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum by 4 | ( 5 | backend 6 | ) 7 | ( 8 | avg_over_time 9 | ( 10 | haproxy_backend_max_sessions [2m] 11 | ) 12 | ) / sum by 13 | ( 14 | backend 15 | ) 16 | ( 17 | avg_over_time 18 | ( 19 | haproxy_backend_limit_sessions [2m] 20 | ) 21 | ) 22 | ) * 100 23 | ) > 80 24 | -------------------------------------------------------------------------------- /tests/resources/formatted/2e2aed13efb482e0f4b71a027c576c4d: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:table:tombstonescannedhistogram:99thpercentile" 4 | } > 1000 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/2f2bdfbd374938d0da09a027a3bf6a53: -------------------------------------------------------------------------------- 1 | node_filesystem_files_free 2 | { 3 | mountpoint="/rootfs" 4 | } / node_filesystem_files 5 | { 6 | mountpoint="/rootfs" 7 | } * 100 < 10 and ON 8 | ( 9 | instance, 10 | device, 11 | mountpoint 12 | ) 13 | node_filesystem_readonly 14 | { 15 | mountpoint="/rootfs" 16 | } == 0 17 | -------------------------------------------------------------------------------- /tests/resources/formatted/3085f81804488dfac43ea0ed9e894c8a: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | server 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_http_responses_total 9 | { 10 | code="5xx" 11 | } [1m] 12 | ) 13 | ) / sum by 14 | ( 15 | server 16 | ) 17 | ( 18 | rate 19 | ( 20 | haproxy_server_http_responses_total [1m] 21 | ) * 100 22 | ) > 5 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/309faac35b97d43054b7f50dc0beaf7e: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:threadpools:internal:antientropystage:currentlyblockedtasks:count" 4 | } > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/30c250d5b994b8bd98bfc53ebd13862a: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | rate 5 | ( 6 | etcd_http_successful_duration_seconds_bucket [1m] 7 | ) 8 | ) > 0.15 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/30dfe4d9bd31585e824fc4e5319be271: -------------------------------------------------------------------------------- 1 | ( 2 | histogram_quantile 3 | ( 4 | 0.99, 5 | sum 6 | ( 7 | rate 8 | ( 9 | loki_request_duration_seconds_bucket 10 | { 11 | route!~"(?i).*tail.*" 12 | } [5m] 13 | ) 14 | ) 15 | by 16 | ( 17 | le 18 | ) 19 | ) 20 | ) > 1 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/313e3c3ea988d078348c59099eba4824: -------------------------------------------------------------------------------- 1 | mysql_slave_status_master_server_id > 0 and ON 2 | ( 3 | instance 4 | ) 5 | mysql_slave_status_slave_sql_running == 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/323efa33184302d23fef32942db94d9d: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:clientrequest:viewwrite:viewwritelatency:99thpercentile", 4 | service="cas" 5 | } > 100000 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/3406caff3871270a823940892a6ce10e: -------------------------------------------------------------------------------- 1 | prometheus_target_interval_length_seconds 2 | { 3 | quantile="0.9" 4 | } > 60 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/35dd9d9b897addb6661ef9c4a5d92a3b: -------------------------------------------------------------------------------- 1 | windows_service_status 2 | { 3 | status="ok" 4 | } != 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/372e3e559cd3e932f550c6ac7f518682: -------------------------------------------------------------------------------- 1 | ( 2 | avg 3 | ( 4 | mongodb_mongod_replset_oplog_head_timestamp - mongodb_mongod_replset_oplog_tail_timestamp 5 | ) - ( 6 | avg 7 | ( 8 | mongodb_mongod_replset_member_optime_date 9 | { 10 | state="PRIMARY" 11 | } 12 | ) - avg 13 | ( 14 | mongodb_mongod_replset_member_optime_date 15 | { 16 | state="SECONDARY" 17 | } 18 | ) 19 | ) 20 | ) <= 0 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/376b5fcdfe13e2bed3fce8638e760e56: -------------------------------------------------------------------------------- 1 | rabbitmq_partitions > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/3939e3dfd95f7c838f6088be5fb2e117: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_number_of_data_nodes < 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/39530e6a688b2a15c72fd94c5a1763d4: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | node_vmstat_pgmajfault [1m] 4 | ) > 1000 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/39741c5b0dc404a8687390e0491cc77a: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | coredns_panics_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/39ad5afa022bc47841d922ee0eea66f6: -------------------------------------------------------------------------------- 1 | ceph_pg_total - ceph_pg_active > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/3a3a580bb207850421262e8ff199d78e: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | traefik_backend_requests_total 6 | { 7 | code=~"4.*" 8 | } [3m] 9 | ) 10 | ) 11 | by 12 | ( 13 | backend 14 | ) / sum 15 | ( 16 | rate 17 | ( 18 | traefik_backend_requests_total [3m] 19 | ) 20 | ) 21 | by 22 | ( 23 | backend 24 | ) * 100 > 5 25 | -------------------------------------------------------------------------------- /tests/resources/formatted/3ae4d713074b2b5218a177a46786fae3: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_target_scrapes_sample_duplicate_timestamp_total [5m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/3b8074526509927589c1e30f3d12b214: -------------------------------------------------------------------------------- 1 | kube_persistentvolume_status_phase 2 | { 3 | phase=~"Failed|Pending", 4 | job="kube-state-metrics" 5 | } > 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/3cd4bd937a5b13850c9455ce204f380b: -------------------------------------------------------------------------------- 1 | mongodb_replset_member_state == 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/3d800d8a44b35e5879d0b81341f84048: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | istio_requests_total 6 | { 7 | reporter="destination", 8 | response_code=~"4.*" 9 | } [5m] 10 | ) 11 | ) / sum 12 | ( 13 | rate 14 | ( 15 | istio_requests_total 16 | { 17 | reporter="destination" 18 | } [5m] 19 | ) 20 | ) * 100 > 5 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/40c101d2dcbf5587289fc601b67a22f6: -------------------------------------------------------------------------------- 1 | rabbitmq_process_open_fds / rabbitmq_process_max_fds * 100 > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/4147c794c7dc4f994cf3fe020d620203: -------------------------------------------------------------------------------- 1 | ( 2 | kube_pod_container_status_restarts_total - kube_pod_container_status_restarts_total 3 | offset 10m >= 1 4 | ) and ignoring 5 | ( 6 | reason 7 | ) 8 | min_over_time 9 | ( 10 | kube_pod_container_status_last_terminated_reason 11 | { 12 | reason="OOMKilled" 13 | } [10m] 14 | ) == 1 15 | -------------------------------------------------------------------------------- /tests/resources/formatted/41f1469d76f9549c73ae1d3cf3a20d3d: -------------------------------------------------------------------------------- 1 | ssl_probe_success == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/42c4a1e9f0ad4293a2823f11648cea91: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | cortex_prometheus_notifications_errors_total [5m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/44c32b3bb7d6b0f5a2cd9fa4842b316f: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:clientrequest:read:unavailables:count" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/45363f5e542b13f0f05206d0a4fc1fa5: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | istio_requests_total 6 | { 7 | reporter="destination", 8 | response_code=~"5.*" 9 | } [5m] 10 | ) 11 | ) / sum 12 | ( 13 | rate 14 | ( 15 | istio_requests_total 16 | { 17 | reporter="destination" 18 | } [5m] 19 | ) 20 | ) * 100 > 5 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/45c2f5d1e79d46705138e208e1fe09f7: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | node_disk_write_time_seconds_total [1m] 4 | ) / rate 5 | ( 6 | node_disk_writes_completed_total [1m] 7 | ) > 0.1 and rate 8 | ( 9 | node_disk_writes_completed_total [1m] 10 | ) > 0 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/461b7d0cc835124fac20df180d819439: -------------------------------------------------------------------------------- 1 | min_over_time 2 | ( 3 | node_timex_sync_status [1m] 4 | ) == 0 and node_timex_maxerror_seconds >= 16 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/467dd2566644e26d502c800eaaf817bf: -------------------------------------------------------------------------------- 1 | min_over_time 2 | ( 3 | sum by 4 | ( 5 | namespace, 6 | pod 7 | ) 8 | ( 9 | kube_pod_status_phase 10 | { 11 | phase=~"Pending|Unknown|Failed" 12 | } 13 | ) [15m:1m]) > 0 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/4699ee30956330789bb287444c305e19: -------------------------------------------------------------------------------- 1 | alertmanager_config_last_reload_successful != 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/46aa895948f144971fd2f880dca4dbb0: -------------------------------------------------------------------------------- 1 | netdata_smartd_log_current_pending_sector_count_sectors_average > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/4710aad682f74be9ef019722131edd8b: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | junos_interface_transmit_bytes [1m] 4 | ) * 8 > 1e+9 * 0.90 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/472a4d6ef6fd9e207fbbfab257d31053: -------------------------------------------------------------------------------- 1 | kube_daemonset_status_number_ready / kube_daemonset_status_desired_number_scheduled * 100 < 100 or kube_daemonset_status_desired_number_scheduled - kube_daemonset_status_current_number_scheduled > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/476d610a875d6efa428ba970f2cb5fc5: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | nginx_http_requests_total 6 | { 7 | status=~"^4.." 8 | } [1m] 9 | ) 10 | ) / sum 11 | ( 12 | rate 13 | ( 14 | nginx_http_requests_total [1m] 15 | ) 16 | ) * 100 > 5 17 | -------------------------------------------------------------------------------- /tests/resources/formatted/47b8fd31faa13be41b34b1c472f86006: -------------------------------------------------------------------------------- 1 | ceph_health_status != 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/47bc1470637a125b9abed39055bc8c35: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_storage_exceptions_total [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/486d59df21d8804cfef4db712d643128: -------------------------------------------------------------------------------- 1 | ceph_osd_utilization > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/48c218a18c0faf76b03d14863bdbbcc0: -------------------------------------------------------------------------------- 1 | mongodb_replset_member_state == 6 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/49cd02974e92c1015f42be22770bcf26: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | thanos_objstore_bucket_operation_failures_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/4ac132bb2d4ee8346ac98795ca684f24: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | backend 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_http_responses_total 9 | { 10 | code="5xx" 11 | } [1m] 12 | ) 13 | ) / sum by 14 | ( 15 | backend 16 | ) 17 | ( 18 | rate 19 | ( 20 | haproxy_server_http_responses_total [1m] 21 | ) * 100 22 | ) > 5 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/4b11da7b96971dab7d6904081699b398: -------------------------------------------------------------------------------- 1 | node_hwmon_temp_crit_alarm_celsius == 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/4ba8bc45a03e88a0490ae667fbf9ade6: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rabbitmq_running 4 | ) < 3 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/4c0581efcfc3cfb0eef4f2aa7fe94cdb: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | sum 4 | ( 5 | label_replace 6 | ( 7 | node_uname_info, 8 | "kernel", 9 | "$1", 10 | "release", 11 | "([0-9]+.[0-9]+.[0-9]+).*" 12 | ) 13 | ) 14 | by 15 | ( 16 | kernel 17 | ) 18 | ) > 1 19 | -------------------------------------------------------------------------------- /tests/resources/formatted/4c58b8111c3317ee7721887159296229: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | nginx_http_requests_total 6 | { 7 | status=~"^5.." 8 | } [1m] 9 | ) 10 | ) / sum 11 | ( 12 | rate 13 | ( 14 | nginx_http_requests_total [1m] 15 | ) 16 | ) * 100 > 5 17 | -------------------------------------------------------------------------------- /tests/resources/formatted/4d61c0c1bcdde463a8c413f7fdfa4433: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | rate 5 | ( 6 | istio_request_duration_milliseconds_bucket [1m] 7 | ) 8 | ) > 1 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/4ed30eb3a4380c1aaed21a70d6f4fb63: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:client:authfailure:count" 6 | } [1m] 7 | ) > 5 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/4eeebd21cca3228b59ab8f40a2d7fc04: -------------------------------------------------------------------------------- 1 | avg by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_cpu_seconds_total 9 | { 10 | mode="iowait" 11 | } [5m] 12 | ) 13 | ) * 100 > 5 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/4f900c97f46487e827bcecb013974b01: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | probe_http_duration_seconds [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/512dadfbc73ce8561229a76a74fd1bf7: -------------------------------------------------------------------------------- 1 | node_hwmon_temp_celsius > 75 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/51b5bfe040fbcddc2697723e6c4572e4: -------------------------------------------------------------------------------- 1 | disk_storage_available / disk_storage_total * 100 < 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/51ee6967c680682380d9c8e5976b37f7: -------------------------------------------------------------------------------- 1 | pgbouncer_pools_server_active_connections > 200 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/52a0461e2309172d5e91d41e7b88afb4: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | backend 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_http_responses_total 9 | { 10 | code="4xx" 11 | } [1m] 12 | ) 13 | ) / sum by 14 | ( 15 | backend 16 | ) 17 | ( 18 | rate 19 | ( 20 | haproxy_server_http_responses_total [1m] 21 | ) * 100 22 | ) > 5 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/5351f61102d3fc070d3efaa673c2aa28: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_disk_read_bytes_total [2m] 9 | ) 10 | ) / 1024 / 1024 > 50 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/5396757274965e70435a14433b1360f9: -------------------------------------------------------------------------------- 1 | ceph_pg_inconsistent > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/541c2e09d6596bfb9576e24794990d19: -------------------------------------------------------------------------------- 1 | default_jenkins_builds_health_score < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/5463ace5e4e049fd967210fd2ee47280: -------------------------------------------------------------------------------- 1 | apache_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/553e4d9667175e13f01cac13aca530de: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | grpc_server_handled_total 6 | { 7 | grpc_code!="OK" 8 | } [1m] 9 | ) 10 | ) 11 | BY 12 | ( 13 | grpc_service, 14 | grpc_method 15 | ) / sum 16 | ( 17 | rate 18 | ( 19 | grpc_server_handled_total [1m] 20 | ) 21 | ) 22 | BY 23 | ( 24 | grpc_service, 25 | grpc_method 26 | ) > 0.01 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/558b2ae0b2595dc81eaec7897bcfd3ab: -------------------------------------------------------------------------------- 1 | node_reboot_required > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/5599c5137f950002466f7d48803397e7: -------------------------------------------------------------------------------- 1 | avg 2 | ( 3 | mongodb_replset_member_optime_date 4 | { 5 | state="PRIMARY" 6 | } 7 | ) - avg 8 | ( 9 | mongodb_replset_member_optime_date 10 | { 11 | state="SECONDARY" 12 | } 13 | ) > 10 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/56064474cd38b8d920ff864761609051: -------------------------------------------------------------------------------- 1 | ( 2 | sum 3 | ( 4 | rate 5 | ( 6 | container_cpu_usage_seconds_total 7 | { 8 | name!="" 9 | } [3m] 10 | ) 11 | ) 12 | BY 13 | ( 14 | instance, 15 | name 16 | ) * 100 17 | ) > 80 18 | -------------------------------------------------------------------------------- /tests/resources/formatted/562659c5dcb9b0b2136d9c41557e1424: -------------------------------------------------------------------------------- 1 | ( 2 | sum 3 | ( 4 | rate 5 | ( 6 | rest_client_requests_total 7 | { 8 | code=~"(4|5).." 9 | } [1m] 10 | ) 11 | ) 12 | by 13 | ( 14 | instance, 15 | job 16 | ) / sum 17 | ( 18 | rate 19 | ( 20 | rest_client_requests_total [1m] 21 | ) 22 | ) 23 | by 24 | ( 25 | instance, 26 | job 27 | ) 28 | ) * 100 > 1 29 | -------------------------------------------------------------------------------- /tests/resources/formatted/56470ecd5c4d46fcd6e2cb1fab7d8d10: -------------------------------------------------------------------------------- 1 | nomad_nomad_job_summary_failed > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/567441a2715bee0760f7f45be9f37e1c: -------------------------------------------------------------------------------- 1 | time 2 | ( 3 | ) - pg_postmaster_start_time_seconds < 60 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/578255c148e46045351b2bc96cc1c968: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | node_network_transmit_errs_total [2m] 4 | ) / rate 5 | ( 6 | node_network_transmit_packets_total [2m] 7 | ) > 0.01 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/581885bd4824b2b53a9ea0874f4f0197: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | speedtest_upload [10m] 4 | ) < 20 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/585d1aa1d9797513feec80ab3211671c: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | grpc_server_handled_total 6 | { 7 | grpc_code!="OK" 8 | } [1m] 9 | ) 10 | ) 11 | BY 12 | ( 13 | grpc_service, 14 | grpc_method 15 | ) / sum 16 | ( 17 | rate 18 | ( 19 | grpc_server_handled_total [1m] 20 | ) 21 | ) 22 | BY 23 | ( 24 | grpc_service, 25 | grpc_method 26 | ) > 0.05 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/5ba8fe4b0876b269ab5f3e544684a8bd: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | frontend 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_frontend_requests_denied_total [2m] 9 | ) 10 | ) > 10 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/5c2e83d4e39b191150e04d4bb7d35f0c: -------------------------------------------------------------------------------- 1 | rabbitmq_connectionsTotal > 1000 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/5c71e8e5ea96a9f45ebc3f474a2a2cf3: -------------------------------------------------------------------------------- 1 | ( 2 | rate 3 | ( 4 | node_network_receive_bytes_total 5 | { 6 | device!~"^tap.*" 7 | } [1m] 8 | ) + rate 9 | ( 10 | node_network_transmit_bytes_total 11 | { 12 | device!~"^tap.*" 13 | } [1m] 14 | ) 15 | ) / node_network_speed_bytes 16 | { 17 | device!~"^tap.*" 18 | } > 0.8 < 10000 19 | -------------------------------------------------------------------------------- /tests/resources/formatted/5cf7206d78ad1318476419622e2059e2: -------------------------------------------------------------------------------- 1 | ( 2 | sum 3 | ( 4 | mongodb_memory 5 | { 6 | type="virtual" 7 | } 8 | ) 9 | BY 10 | ( 11 | instance 12 | ) / sum 13 | ( 14 | mongodb_memory 15 | { 16 | type="mapped" 17 | } 18 | ) 19 | BY 20 | ( 21 | instance 22 | ) 23 | ) > 3 24 | -------------------------------------------------------------------------------- /tests/resources/formatted/5da6a38c886aa8b734349aea03267adc: -------------------------------------------------------------------------------- 1 | elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes * 100 < 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/5dc5aa0b4aa448f2a6645c75e34698ba: -------------------------------------------------------------------------------- 1 | ceph_osd_perf_apply_latency_seconds > 5 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/5e19fd0fdd2e74f2f7a32349159fd128: -------------------------------------------------------------------------------- 1 | apiserver_client_certificate_expiration_seconds_count 2 | { 3 | job="apiserver" 4 | } > 0 and histogram_quantile 5 | ( 6 | 0.01, 7 | sum by 8 | ( 9 | job, 10 | le 11 | ) 12 | ( 13 | rate 14 | ( 15 | apiserver_client_certificate_expiration_seconds_bucket 16 | { 17 | job="apiserver" 18 | } [5m] 19 | ) 20 | ) 21 | ) < 24 * 60 * 60 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/5ebe07d7a073983e7862a5fc6c0743b9: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | proxy 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_frontend_denied_connections_total [2m] 9 | ) 10 | ) > 10 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/5ee1becba2ccca75b6fd34f26d93b959: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | sum 5 | ( 6 | rate 7 | ( 8 | promtail_request_duration_seconds_bucket [5m] 9 | ) 10 | ) 11 | by 12 | ( 13 | le 14 | ) 15 | ) > 1 16 | -------------------------------------------------------------------------------- /tests/resources/formatted/5f58e450a64c5f61ff61615bb2c403fb: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pg_stat_ssl_compression 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/5f5e9e08b25672f614ea90660623d65b: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | ( 4 | rate 5 | ( 6 | pulsar_function_user_exceptions_total 7 | { 8 | } [1m] 9 | ) + rate 10 | ( 11 | pulsar_function_system_exceptions_total 12 | { 13 | } [1m] 14 | ) 15 | ) > 10 16 | ) 17 | by 18 | ( 19 | name 20 | ) 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/5fc3b72e21a36ace4758bbb5ef4dc65b: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | node_edac_correctable_errors_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/601c919905fec9701fbfa41cca3647c9: -------------------------------------------------------------------------------- 1 | absent 2 | ( 3 | container_last_seen 4 | ) 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/602bee0be8a56902b7fd87950f698897: -------------------------------------------------------------------------------- 1 | 100 / netdata_system_ram_MB_average * netdata_system_ram_MB_average 2 | { 3 | dimension=~"free|cached" 4 | } < 20 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/626d523a34ed3c1656c0698100cf2473: -------------------------------------------------------------------------------- 1 | consul_catalog_service_node_healthy == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/628e7d78033ced13b5b101b6c664f5b2: -------------------------------------------------------------------------------- 1 | ceph_pg_incomplete > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/62c3da4578f624ed2ca800a87a6018df: -------------------------------------------------------------------------------- 1 | rabbitmq_process_resident_memory_bytes / rabbitmq_resident_memory_limit_bytes * 100 > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/6346e927541043839869beb1474911cd: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:clientrequest:read:failures:oneminuterate" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/63a74fd665adab43030e192fe52d2929: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | postgresql_errors_total 4 | { 5 | type="deadlock_detected" 6 | } [1m] 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/63e5b2b69a0b55eb797a33142ca51ac1: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | istio_request_duration_milliseconds_sum [1m] 4 | ) / rate 5 | ( 6 | istio_request_duration_milliseconds_count [1m] 7 | ) > 0.1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/6535aa472094e27e4240bf49da2840dc: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | solr_metrics_core_update_handler_errors_total [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/673a4d7c2ba602c206ad0eec7df5d4ee: -------------------------------------------------------------------------------- 1 | rabbitmq_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/686a3acb521e1ac08f34132f6b5b38f7: -------------------------------------------------------------------------------- 1 | ceph_pg_activating > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/68733903b224f31b1d12971670b37f12: -------------------------------------------------------------------------------- 1 | 100 * sum 2 | ( 3 | rate 4 | ( 5 | loki_request_duration_seconds_count 6 | { 7 | status_code=~"5.." 8 | } [1m] 9 | ) 10 | ) 11 | by 12 | ( 13 | namespace, 14 | job, 15 | route 16 | ) / sum 17 | ( 18 | rate 19 | ( 20 | loki_request_duration_seconds_count [1m] 21 | ) 22 | ) 23 | by 24 | ( 25 | namespace, 26 | job, 27 | route 28 | ) > 10 29 | -------------------------------------------------------------------------------- /tests/resources/formatted/688c79ecded72c6e7c58b6d4f1f51d86: -------------------------------------------------------------------------------- 1 | ( 2 | node_timex_offset_seconds > 0.05 and deriv 3 | ( 4 | node_timex_offset_seconds [5m] 5 | ) >= 0 6 | ) or ( 7 | node_timex_offset_seconds < -0.05 and deriv 8 | ( 9 | node_timex_offset_seconds [5m] 10 | ) <= 0 11 | ) 12 | -------------------------------------------------------------------------------- /tests/resources/formatted/6956e54febb750f78bd2d697db1c31a5: -------------------------------------------------------------------------------- 1 | prometheus_config_last_reload_successful != 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/696658abb97057f51361a2d9d94bb8db: -------------------------------------------------------------------------------- 1 | ( 2 | sum by 3 | ( 4 | proxy 5 | ) 6 | ( 7 | rate 8 | ( 9 | haproxy_backend_connection_errors_total [1m] 10 | ) 11 | ) 12 | ) > 100 13 | -------------------------------------------------------------------------------- /tests/resources/formatted/69b85345930e4e1ee27cf9fd96793dab: -------------------------------------------------------------------------------- 1 | ( 2 | pg_stat_user_tables_last_autoanalyze > 0 3 | ) and ( 4 | time 5 | ( 6 | ) - pg_stat_user_tables_last_autoanalyze 7 | ) > 24 * 60 * 60 * 10 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/69c203c12117f92a4b81ecb37aaf2a66: -------------------------------------------------------------------------------- 1 | mongodb_mongod_metrics_cursor_open 2 | { 3 | state="total" 4 | } > 10 * 1000 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/69dcf611b26f4d8a3ae17dafeccf9dc2: -------------------------------------------------------------------------------- 1 | last_over_time 2 | ( 3 | basebackup 4 | { 5 | } [12h] 6 | offset 5m 7 | ) > 0 unless on 8 | ( 9 | fire 10 | ) 11 | last_over_time 12 | ( 13 | progress 14 | { 15 | } [12h] 16 | ) > 0 17 | -------------------------------------------------------------------------------- /tests/resources/formatted/6aa868b60cbaf4ce158266e556fbe15d: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | redis_instance_info 4 | { 5 | role="master" 6 | } 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/6ae4af3df41f87470e3c84f2ded415d8: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_head_truncations_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/6b51b71f728da4866dd295b3e97b2891: -------------------------------------------------------------------------------- 1 | 100 / netdata_disk_space_GB_average * netdata_disk_space_GB_average 2 | { 3 | dimension=~"avail|cached" 4 | } < 20 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/6c21a01cdba0a69d58710c7269cb62ea: -------------------------------------------------------------------------------- 1 | redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/6c6283280102b331df52dab9f014af3e: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_entry_size_overflow > 0 4 | ) 5 | by 6 | ( 7 | topic 8 | ) 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/6d32823628e23c732c297fc7b92553ce: -------------------------------------------------------------------------------- 1 | kubelet_volume_stats_available_bytes / kubelet_volume_stats_capacity_bytes * 100 < 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/6ece92e701544479fe0e7cef82405e84: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:threadpools:internal:compactionexecutor:currentlyblockedtasks:count" 4 | } > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/6f2a62df4b51bdbc8da4957764ad8707: -------------------------------------------------------------------------------- 1 | ceph_osd_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/6f9acfa0498e6b25170500ecb935f226: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | netdata_cpu_cpu_percentage_average 4 | { 5 | dimension="idle" 6 | } [1m] 7 | ) > 80 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/7006fa216f3c8156f7a003dbc077c116: -------------------------------------------------------------------------------- 1 | abs 2 | ( 3 | ceph_monitor_clock_skew_seconds 4 | ) > 0.2 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/70ceec0763cbbd9d05addad72bbb1e8a: -------------------------------------------------------------------------------- 1 | time 2 | ( 3 | ) - rabbitmq_queue_head_message_timestamp 4 | { 5 | queue="my-queue" 6 | } > 60 7 | -------------------------------------------------------------------------------- /tests/resources/formatted/71734b49170e5d199b5082f64a26622a: -------------------------------------------------------------------------------- 1 | erlang_vm_dist_node_state < 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/71b3d2d10c7585936d658d167be3f214: -------------------------------------------------------------------------------- 1 | cassandra_table_estimated_pending_compactions > 100 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/73dc546ba11f418b933e74343498f1c9: -------------------------------------------------------------------------------- 1 | jenkins_health_check_score < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/74681db3101935154d03e554af87a332: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | mssql_deadlocks [1m] 4 | ) > 5 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/754b9b5ebf9f13ac0b1dc209a430762e: -------------------------------------------------------------------------------- 1 | node_md_disks 2 | { 3 | state="failed" 4 | } > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/7556330e9311efd33244e6040aec0319: -------------------------------------------------------------------------------- 1 | ssl_ocsp_response_status == 2 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/75b459eebb4e022cb8526fe6fb47a3a3: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | mixer_runtime_dispatches_total 6 | { 7 | adapter=~"prometheus" 8 | } [1m] 9 | ) 10 | ) < 180 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/76eb300208be53bf5e01e726ff9410b7: -------------------------------------------------------------------------------- 1 | min 2 | ( 3 | kube_deployment_status_replicas_available 4 | { 5 | deployment="istio-ingressgateway", 6 | namespace="istio-system" 7 | } 8 | ) 9 | without 10 | ( 11 | instance, 12 | pod 13 | ) < 2 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/785669509a34c443e9985adcd7726ca7: -------------------------------------------------------------------------------- 1 | mongodb_mongod_replset_member_optime_date 2 | { 3 | state="PRIMARY" 4 | } - ON 5 | ( 6 | set 7 | ) 8 | mongodb_mongod_replset_member_optime_date 9 | { 10 | state="SECONDARY" 11 | } > 10 12 | -------------------------------------------------------------------------------- /tests/resources/formatted/78dccb1f900387b8c8f00a73f08f2a74: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | proxy 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_backend_current_queue [2m] 9 | ) 10 | ) > 0 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/7916718a182064e785a7e348fa586b3d: -------------------------------------------------------------------------------- 1 | ( 2 | node_filesystem_avail_bytes * 100 3 | ) / node_filesystem_size_bytes < 10 and ON 4 | ( 5 | instance, 6 | device, 7 | mountpoint 8 | ) 9 | node_filesystem_readonly == 0 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/79d2bce78b9a82251a13e91a6cbd5cd3: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | kafka_topic_partition_in_sync_replica 4 | ) 5 | by 6 | ( 7 | topic 8 | ) < 3 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/7a469066b76a99876bbf3723e4199a36: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_status 2 | { 3 | color="yellow" 4 | } == 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/7a916e31d2524601d8f6cffa80337547: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | pilot_xds_push_errors [1m] 6 | ) 7 | ) / sum 8 | ( 9 | rate 10 | ( 11 | pilot_xds_pushes [1m] 12 | ) 13 | ) * 100 > 5 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/7ae1ad3880a26263a7f9e22c5ede2191: -------------------------------------------------------------------------------- 1 | absent 2 | ( 3 | up 4 | { 5 | job="prometheus" 6 | } 7 | ) 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/7b352062ab815cc81d3ac1a08b2125d0: -------------------------------------------------------------------------------- 1 | kube_replicaset_spec_replicas != kube_replicaset_status_ready_replicas 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/7bd140be051625e84487b5ca34262dab: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | node 4 | ) 5 | ( 6 | ( 7 | kube_pod_status_phase 8 | { 9 | phase="Running" 10 | } == 1 11 | ) + on 12 | ( 13 | uid 14 | ) 15 | group_left 16 | ( 17 | node 18 | ) 19 | ( 20 | 0 * kube_pod_info 21 | { 22 | pod_template_hash="" 23 | } 24 | ) 25 | ) / sum by 26 | ( 27 | node 28 | ) 29 | ( 30 | kube_node_status_allocatable 31 | { 32 | resource="pods" 33 | } 34 | ) * 100 > 90 35 | -------------------------------------------------------------------------------- /tests/resources/formatted/7cd2763bc3dbee09d4de90ca0ec40d65: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | netdata_smartd_log_reallocated_sectors_count_sectors_average [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/7d276cd586d634b9f2d6c5fd52ca3844: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | netdata_cpu_cpu_percentage_average 4 | { 5 | dimension="steal" 6 | } [1m] 7 | ) > 10 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/7d711161d59ef2e285d742780cf857e2: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | count 4 | ( 5 | rabbitmq_build_info 6 | ) 7 | by 8 | ( 9 | rabbitmq_version 10 | ) 11 | ) > 1 12 | -------------------------------------------------------------------------------- /tests/resources/formatted/80a68e60840ee3cc16056b90f58ce304: -------------------------------------------------------------------------------- 1 | rabbitmq_connections > 1000 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/810c61d66460179160a8965c0f58bee8: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | solr_metrics_core_errors_total 4 | { 5 | category="QUERY" 6 | } [1m] 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/81914ca9a3c337205e98cbcec28c6612: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_network_receive_bytes_total [2m] 9 | ) 10 | ) / 1024 / 1024 > 100 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/81eeaf4bfc7d77f18bf460ad1587ffa5: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | etcd_http_failed_total [1m] 6 | ) 7 | ) 8 | BY 9 | ( 10 | method 11 | ) / sum 12 | ( 13 | rate 14 | ( 15 | etcd_http_received_total [1m] 16 | ) 17 | ) 18 | BY 19 | ( 20 | method 21 | ) > 0.05 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/821f299345074953b4793c7c2ff0a5b4: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_number_of_nodes < 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/833ea7953f12ebadb3e86e690783cb64: -------------------------------------------------------------------------------- 1 | 100 - ( 2 | avg by 3 | ( 4 | instance 5 | ) 6 | ( 7 | rate 8 | ( 9 | node_cpu_seconds_total 10 | { 11 | mode="idle" 12 | } [2m] 13 | ) 14 | ) * 100 15 | ) > 80 16 | -------------------------------------------------------------------------------- /tests/resources/formatted/840396027241a5034f51027aeea75824: -------------------------------------------------------------------------------- 1 | rabbitmq_node_mem_used / rabbitmq_node_mem_limit * 100 > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/854a7f019b58a47e00e5292f3d09fcf3: -------------------------------------------------------------------------------- 1 | kube_deployment_spec_replicas != kube_deployment_status_replicas_available 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/860065ebe2a6a84ad538f7b11cf10ad7: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | kafka_consumergroup_lag 4 | ) 5 | by 6 | ( 7 | consumergroup 8 | ) > 50 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/860b07454eb5921bafb47acc47808bb6: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | phpfpm_max_children_reached_total 4 | ) 5 | by 6 | ( 7 | instance 8 | ) > 0 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/8614a9b55fe3da904993e42f60b36f3c: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | pg_stat_database_xact_commit [1m] 4 | ) < 10 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/86398a8fde822df9c98e3045d5ac4928: -------------------------------------------------------------------------------- 1 | predict_linear 2 | ( 3 | kubelet_volume_stats_available_bytes [6h], 4 | 4 * 24 * 3600 5 | ) < 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/8651fa56c935aa7022eb7757c7eb11d4: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | rate 5 | ( 6 | etcd_network_peer_round_trip_time_seconds_bucket [1m] 7 | ) 8 | ) > 0.15 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/86dec675ee5c679dd90515f5441fa0ba: -------------------------------------------------------------------------------- 1 | ( 2 | node_filesystem_avail_bytes * 100 3 | ) / node_filesystem_size_bytes < 10 and ON 4 | ( 5 | instance, 6 | device, 7 | mountpoint 8 | ) 9 | predict_linear 10 | ( 11 | node_filesystem_avail_bytes 12 | { 13 | fstype!~"tmpfs" 14 | } [1h], 15 | 24 * 3600 16 | ) < 0 and ON 17 | ( 18 | instance, 19 | device, 20 | mountpoint 21 | ) 22 | node_filesystem_readonly == 0 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/8763ebaf8945908d324cdd1da0660b49: -------------------------------------------------------------------------------- 1 | ( 2 | sum by 3 | ( 4 | proxy 5 | ) 6 | ( 7 | rate 8 | ( 9 | haproxy_server_connection_errors_total [1m] 10 | ) 11 | ) 12 | ) > 100 13 | -------------------------------------------------------------------------------- /tests/resources/formatted/87df883f6d318f26f6a857ab35939df6: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_checkpoint_creations_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/885d80812e1449909816abc93824ca63: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | sum 5 | ( 6 | rate 7 | ( 8 | nginx_http_request_duration_seconds_bucket [2m] 9 | ) 10 | ) 11 | by 12 | ( 13 | host, 14 | node 15 | ) 16 | ) > 3 17 | -------------------------------------------------------------------------------- /tests/resources/formatted/8a3b890f2c55261b66b3d3666166383f: -------------------------------------------------------------------------------- 1 | pg_replication_slots_active == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/8a6f9e14e2389d460fac8522366a38aa: -------------------------------------------------------------------------------- 1 | avg 2 | ( 3 | vault_token_create_count - vault_token_store_count 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/8afe8696804a22131435ec64027a1a67: -------------------------------------------------------------------------------- 1 | ceph_pg_down > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/8b0c5688926d5f9aa5ef4aff2d83a1c1: -------------------------------------------------------------------------------- 1 | pg_bloat_btree_bloat_pct > 80 and on 2 | ( 3 | idxname 4 | ) 5 | ( 6 | pg_bloat_btree_real_size > 100000000 7 | ) 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/8bbb6190b9d26fd86243334f2d64cec7: -------------------------------------------------------------------------------- 1 | probe_ssl_earliest_cert_expiry - time 2 | ( 3 | ) <= 0 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/8c1963032ecbdf11d9415fcc5b7649c2: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_wal_truncations_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/8c8188e5b3b3830fad7f1c539f158c87: -------------------------------------------------------------------------------- 1 | avg by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_cpu_seconds_total 9 | { 10 | mode="steal" 11 | } [5m] 12 | ) 13 | ) * 100 > 10 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/8d1ed05145df4646cbe68fea32d5f073: -------------------------------------------------------------------------------- 1 | probe_ssl_earliest_cert_expiry - time 2 | ( 3 | ) < 86400 * 3 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/8e04e3fe39c13c9b23ca575b4f6b5006: -------------------------------------------------------------------------------- 1 | kafka_burrow_topic_partition_offset - on 2 | ( 3 | partition, 4 | cluster, 5 | topic 6 | ) 7 | group_right 8 | ( 9 | ) 10 | kafka_burrow_partition_current_offset >= ( 11 | kafka_burrow_topic_partition_offset 12 | offset 15m - on 13 | ( 14 | partition, 15 | cluster, 16 | topic 17 | ) 18 | group_right 19 | ( 20 | ) 21 | kafka_burrow_partition_current_offset 22 | offset 15m 23 | ) AND kafka_burrow_topic_partition_offset - on 24 | ( 25 | partition, 26 | cluster, 27 | topic 28 | ) 29 | group_right 30 | ( 31 | ) 32 | kafka_burrow_partition_current_offset > 0 33 | -------------------------------------------------------------------------------- /tests/resources/formatted/8e2b3a4b10689b8c5fc5f7dafdb14e17: -------------------------------------------------------------------------------- 1 | cortex_ring_members 2 | { 3 | state="Unhealthy", 4 | name="ingester" 5 | } > 0 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/8f10256fd95b268c3ee15c39917cab9d: -------------------------------------------------------------------------------- 1 | vmware_vm_snapshots > 3 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/8f32ec316b8147a4f7df0948bc1d87c1: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:threadpools:internal:memtableflushwriter:currentlyblockedtasks:count" 4 | } > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/903f180c3b58e71c181fa1da8cd1fea1: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | solr_metrics_core_errors_total 4 | { 5 | category="REPLICATION" 6 | } [1m] 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/90c429494010758bbba1e5ccbf3bf22e: -------------------------------------------------------------------------------- 1 | jenkins_node_offline_value > 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/912cf3e40b70e85da6df06679e13cee0: -------------------------------------------------------------------------------- 1 | avg by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | mongodb_connections 9 | { 10 | state="current" 11 | } [1m] 12 | ) 13 | ) / avg by 14 | ( 15 | instance 16 | ) 17 | ( 18 | sum 19 | ( 20 | mongodb_connections 21 | ) 22 | by 23 | ( 24 | instance 25 | ) 26 | ) * 100 > 80 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/913f9afa26cfedeee2ddb555b42baebe: -------------------------------------------------------------------------------- 1 | probe_http_status_code <= 199 OR probe_http_status_code >= 400 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/91480a745b0811da5159692f50c98e06: -------------------------------------------------------------------------------- 1 | redis_connected_clients > 100 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/93307d3ddf8b9e0ed7a3c91b6c7f6801: -------------------------------------------------------------------------------- 1 | node_filesystem_files_free 2 | { 3 | mountpoint="/rootfs" 4 | } / node_filesystem_files 5 | { 6 | mountpoint="/rootfs" 7 | } * 100 < 10 and predict_linear 8 | ( 9 | node_filesystem_files_free 10 | { 11 | mountpoint="/rootfs" 12 | } [1h], 13 | 24 * 3600 14 | ) < 0 and ON 15 | ( 16 | instance, 17 | device, 18 | mountpoint 19 | ) 20 | node_filesystem_readonly 21 | { 22 | mountpoint="/rootfs" 23 | } == 0 24 | -------------------------------------------------------------------------------- /tests/resources/formatted/93bcccd1affab5fdda7951b0ad2519dd: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | server 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_http_responses_total 9 | { 10 | code="4xx" 11 | } [1m] 12 | ) 13 | ) / sum by 14 | ( 15 | server 16 | ) 17 | ( 18 | rate 19 | ( 20 | haproxy_server_http_responses_total [1m] 21 | ) * 100 22 | ) > 5 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/94d308fd2c3e3f025079b7487664e1fa: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | cassandra_endpoint_active 4 | ) 5 | by 6 | ( 7 | cassandra_cluster, 8 | instance, 9 | exported_endpoint 10 | ) < 1 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/95ea62207f4c66059d9c45231ffb07e9: -------------------------------------------------------------------------------- 1 | mongodb_replset_member_state == 9 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/967b29cebf70b8459d9d02243bb10eb9: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:commitlog:pendingtasks:value" 4 | } > 15 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/97a1ba68e7e23f09b842d480566f15c6: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | container_cpu_cfs_throttled_seconds_total [3m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/97e795ef6d85034c8d90fc85c0717b3f: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_target_scrapes_exceeded_sample_limit_total [10m] 4 | ) > 10 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/99030513360ce58efcf6cb5836e42265: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | backend 4 | ) 5 | ( 6 | haproxy_backend_current_queue 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/99485021f061e146958e352a31cff150: -------------------------------------------------------------------------------- 1 | rabbitmq_queue_consumers < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/9a8d128a2cb02bbf376664643a2d4663: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_subscription_back_log 4 | ) 5 | by 6 | ( 7 | subscription 8 | ) > 5000 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/9b243ba92768c10d5afbea4ad1ce6461: -------------------------------------------------------------------------------- 1 | probe_success == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/9b63d4abd4dd9447751963d696c27670: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | etcd_server_leader_changes_seen_total [10m] 4 | ) > 2 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/9b88a66bf2176550ee514dc294bb0718: -------------------------------------------------------------------------------- 1 | ( 2 | sum by 3 | ( 4 | instance 5 | ) 6 | ( 7 | jvm_memory_used_bytes 8 | { 9 | area="heap" 10 | } 11 | ) / sum by 12 | ( 13 | instance 14 | ) 15 | ( 16 | jvm_memory_max_bytes 17 | { 18 | area="heap" 19 | } 20 | ) 21 | ) * 100 > 80 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/9b94bcee243c8df484e196fe7e064320: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | apiserver_request_total 6 | { 7 | job="apiserver", 8 | code=~"^(?:5..)$" 9 | } [1m] 10 | ) 11 | ) / sum 12 | ( 13 | rate 14 | ( 15 | apiserver_request_total 16 | { 17 | job="apiserver" 18 | } [1m] 19 | ) 20 | ) * 100 > 3 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/9be319902fc0db726468f7b69bf0ce1d: -------------------------------------------------------------------------------- 1 | max without 2 | ( 3 | revision 4 | ) 5 | ( 6 | kube_statefulset_status_current_revision unless kube_statefulset_status_update_revision 7 | ) * ( 8 | kube_statefulset_replicas != kube_statefulset_status_replicas_updated 9 | ) 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/9be388f12e6b8f08d9070945290764d9: -------------------------------------------------------------------------------- 1 | kube_statefulset_status_replicas_ready != kube_statefulset_status_replicas 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/9c0a70d5df2439364a549e2f816a70a9: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_network_transmit_bytes_total [2m] 9 | ) 10 | ) / 1024 / 1024 > 100 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/9cce20a2da08e50af5d17899d7248e45: -------------------------------------------------------------------------------- 1 | openebs_used_pool_capacity_percent > 80 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/9d5b3d647ad0e351fadbd3e78f62ff4a: -------------------------------------------------------------------------------- 1 | solr_collections_live_nodes < 2 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/9d8a26c2a25cd9604a110b34a2117bf1: -------------------------------------------------------------------------------- 1 | delta 2 | ( 3 | redis_connected_slaves [1m] 4 | ) < 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/9da87d3cc308f5bed641b0b0cc9d75ce: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | request_errors_total [1m] 6 | ) 7 | ) 8 | by 9 | ( 10 | deployment, 11 | statefulset, 12 | daemonset 13 | ) / sum 14 | ( 15 | rate 16 | ( 17 | request_total [1m] 18 | ) 19 | ) 20 | by 21 | ( 22 | deployment, 23 | statefulset, 24 | daemonset 25 | ) * 100 > 10 26 | -------------------------------------------------------------------------------- /tests/resources/formatted/9e1af4713b6d15905fdc3c5f9bbf4619: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | probe_duration_seconds [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/9e669756c6b6af8d132936f5ef1bae30: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | pg_txid_current [1m] 4 | ) < 5 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/9e7a24dceaaba51e56b901123261ad2d: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | process_start_time_seconds 4 | { 5 | job=~"prometheus|pushgateway|alertmanager" 6 | } [15m] 7 | ) > 2 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/9ec6ca010beade5de8794f0b8a6cf1f2: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | sum 5 | ( 6 | rate 7 | ( 8 | apiserver_request_latencies_bucket 9 | { 10 | subresource!="log", 11 | verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$" 12 | } [10m] 13 | ) 14 | ) 15 | WITHOUT 16 | ( 17 | instance, 18 | resource 19 | ) 20 | ) / 1e+06 > 1 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/9fb7915f2ac7725445b8431081b2bedb: -------------------------------------------------------------------------------- 1 | pg_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/a03a6985f6879f83086f757649440c19: -------------------------------------------------------------------------------- 1 | nomad_nomad_job_summary_queued > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/a14c3e20a5f838d3f455fb2f0c9353ff: -------------------------------------------------------------------------------- 1 | prometheus_notifications_alertmanagers_discovered < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/a18d228d7dbb9de47526cbf910ae8194: -------------------------------------------------------------------------------- 1 | time 2 | ( 3 | ) - kube_cronjob_next_schedule_time > 3600 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/a1b045ac219fb2cb5060e752b4ad98a0: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | pgbouncer_errors_count 4 | { 5 | errmsg="no more connections allowed (max_client_conn)" 6 | } [30s] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/a2a79a405d4dfd8d54d9530cd01a8e3b: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum by 4 | ( 5 | server 6 | ) 7 | ( 8 | rate 9 | ( 10 | haproxy_server_http_responses_total 11 | { 12 | code="4xx" 13 | } [1m] 14 | ) 15 | ) / sum by 16 | ( 17 | server 18 | ) 19 | ( 20 | rate 21 | ( 22 | haproxy_server_http_responses_total [1m] 23 | ) 24 | ) 25 | ) * 100 26 | ) > 5 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/a2e400663d5b948fabdd576b07b36b6f: -------------------------------------------------------------------------------- 1 | cassandra_stats 2 | { 3 | name="org:apache:cassandra:metrics:threadpools:internal:antientropystage:pendingtasks:value" 4 | } > 2 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/a3585bd5c5d7eccbe0349f54b0afdaa2: -------------------------------------------------------------------------------- 1 | pg_replication_is_replica and changes 2 | ( 3 | pg_replication_is_replica [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/a71e87c9ebc5a6f9f1fd53bce2974c96: -------------------------------------------------------------------------------- 1 | ( 2 | sum 3 | ( 4 | container_fs_io_current 5 | { 6 | name!="" 7 | } 8 | ) 9 | BY 10 | ( 11 | instance, 12 | name 13 | ) * 100 14 | ) > 80 15 | -------------------------------------------------------------------------------- /tests/resources/formatted/a74db82ff79fca33ab9ace33669a99e5: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | instance 4 | ) 5 | ( 6 | rate 7 | ( 8 | node_disk_written_bytes_total [2m] 9 | ) 10 | ) / 1024 / 1024 > 50 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/a82586407b5dce3b0e8f6a3c6620680d: -------------------------------------------------------------------------------- 1 | kube_horizontalpodautoscaler_status_condition 2 | { 3 | status="false", 4 | condition="ScalingActive" 5 | } == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/a83fe2e1906479bc7b94337f5b48f48d: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | increase 4 | ( 5 | loki_panic_total [10m] 6 | ) 7 | ) 8 | by 9 | ( 10 | namespace, 11 | job 12 | ) > 0 13 | -------------------------------------------------------------------------------- /tests/resources/formatted/ab6bfc017c834c4a76dcf92a29451db1: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_rule_evaluation_failures_total [3m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/ab6e8918af68d62a26180b7cfb435502: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | node_network_receive_errs_total [2m] 4 | ) / rate 5 | ( 6 | node_network_receive_packets_total [2m] 7 | ) > 0.01 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/aca4452a86a43f5013946be04129554a: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | mongodb_metrics_cursor_timed_out_total [1m] 4 | ) > 100 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/acb378b382e78b0938880afaef72055d: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | sum 5 | ( 6 | rate 7 | ( 8 | grpc_server_handling_seconds_bucket 9 | { 10 | grpc_type="unary" 11 | } [1m] 12 | ) 13 | ) 14 | by 15 | ( 16 | grpc_service, 17 | grpc_method, 18 | le 19 | ) 20 | ) > 0.15 21 | -------------------------------------------------------------------------------- /tests/resources/formatted/acb39669ae58402dedd640c92bd01ba4: -------------------------------------------------------------------------------- 1 | redis_memory_used_bytes / redis_memory_max_bytes * 100 > 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/adc0d001ea533931b54bb3e678875d78: -------------------------------------------------------------------------------- 1 | ( 2 | sum by 3 | ( 4 | instance 5 | ) 6 | ( 7 | apache_workers 8 | { 9 | state="busy" 10 | } 11 | ) / sum by 12 | ( 13 | instance 14 | ) 15 | ( 16 | apache_scoreboard 17 | ) 18 | ) * 100 > 80 19 | -------------------------------------------------------------------------------- /tests/resources/formatted/ae747f6e7b15891a2c230cf532444994: -------------------------------------------------------------------------------- 1 | node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/aed4df024f814b3d2bdf8ec9a587c75a: -------------------------------------------------------------------------------- 1 | mongodb_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/af6a6f63a513f6a1c1f3ee53b3369fb2: -------------------------------------------------------------------------------- 1 | ceph_pg_backfill_toofull > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/b0241bc01435538f42afb53ea7630a70: -------------------------------------------------------------------------------- 1 | ( 2 | rate 3 | ( 4 | node_context_switches_total [5m] 5 | ) 6 | ) / ( 7 | count without 8 | ( 9 | cpu, 10 | mode 11 | ) 12 | ( 13 | node_cpu_seconds_total 14 | { 15 | mode="idle" 16 | } 17 | ) 18 | ) > 1000 19 | -------------------------------------------------------------------------------- /tests/resources/formatted/b160ba1c3167f65eea978c3377e10a88: -------------------------------------------------------------------------------- 1 | ( 2 | count 3 | ( 4 | redis_instance_info 5 | { 6 | role="master" 7 | } 8 | ) or vector 9 | ( 10 | 0 11 | ) 12 | ) < 1 13 | -------------------------------------------------------------------------------- /tests/resources/formatted/b1ffa03dbc9d29ac7d40f1098643a69b: -------------------------------------------------------------------------------- 1 | pg_exporter_last_scrape_error > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/b2bc71a2e39068d120b84644ba37fcaa: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:storage:exceptions:count" 6 | } [1m] 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/b555238dbc39d949ac0a48c7ea8ee0f5: -------------------------------------------------------------------------------- 1 | 100 - ( 2 | ( 3 | windows_os_physical_memory_free_bytes / windows_cs_physical_memory_bytes 4 | ) * 100 5 | ) > 90 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/b582f9ce383112a2556942cefc525d44: -------------------------------------------------------------------------------- 1 | ( 2 | freeswitch_session_active * 100 / freeswitch_session_limit 3 | ) > 80 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/b5b05b196fa259d4d694c314cfd385bf: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_status 2 | { 3 | color="red" 4 | } == 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/b5bdeed6c55bf2a80f55dc5610cfaeb6: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | haproxy_server_max_sessions > 0 4 | ) * 100 5 | ) / ( 6 | haproxy_server_limit_sessions > 0 7 | ) > 80 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/b5bee127c4f55e78a4a7d420a3137f1c: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | bookie_ledger_dir__pulsar_data_bookkeeper_ledgers_usage 4 | ) 5 | by 6 | ( 7 | kubernetes_pod_name 8 | ) > 75 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/b617831e2fb322332dad8a9c36064e9c: -------------------------------------------------------------------------------- 1 | haproxy_backend_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/b8a78d5b2e725a02699a7e5ee966009e: -------------------------------------------------------------------------------- 1 | ( 2 | sum by 3 | ( 4 | server 5 | ) 6 | ( 7 | rate 8 | ( 9 | haproxy_server_response_errors_total [1m] 10 | ) 11 | ) / sum by 12 | ( 13 | server 14 | ) 15 | ( 16 | rate 17 | ( 18 | haproxy_server_http_responses_total [1m] 19 | ) 20 | ) 21 | ) * 100 > 5 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/b8dc55a63b0f2e1628ff082a6e508739: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | pg_stat_database_xact_rollback 4 | { 5 | datname!~"template.*" 6 | } [3m] 7 | ) / rate 8 | ( 9 | pg_stat_database_xact_commit 10 | { 11 | datname!~"template.*" 12 | } [3m] 13 | ) > 0.02 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/b9109bd54fa774b46268a0e8adecc2be: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | pilot_duplicate_envoy_clusters 6 | { 7 | } [5m] 8 | ) 9 | ) > 0 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/b91bbcc9a4a040673ba6f8210d447e7d: -------------------------------------------------------------------------------- 1 | kube_node_status_condition 2 | { 3 | condition="MemoryPressure", 4 | status="true" 5 | } == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/b920fd8cce6d7b56ff26d5f5f69bf46c: -------------------------------------------------------------------------------- 1 | kube_deployment_status_observed_generation != kube_deployment_metadata_generation 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/bb9e86500867ae3e5bccb07721f40172: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_reloads_failures_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/bbb9dacab2fe41400fa4631b365dec84: -------------------------------------------------------------------------------- 1 | redis_connected_clients < 5 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/bc84aa4c846115e00b2734bc675afbb9: -------------------------------------------------------------------------------- 1 | vault_token_count_by_ttl 2 | { 3 | creation_ttl="+Inf" 4 | } > 3 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/be2762c548ce67264fcf9a247283c397: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | etcd_server_id 4 | ) % 2 == 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/bfe4ff310513226699011fd0dc0f1bb4: -------------------------------------------------------------------------------- 1 | mongodb_metrics_cursor_open 2 | { 3 | state="total_open" 4 | } > 10000 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/bfe74d7f66c90bb789056b9ed16b6a74: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | netdata_smartd_log_offline_uncorrectable_sector_count_sectors_average [2m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/bfeeb10894ff9b4e8c440887efbf2c4c: -------------------------------------------------------------------------------- 1 | vmware_vm_mem_usage_average / 100 >= 80 and vmware_vm_mem_usage_average / 100 < 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c106f28bda72a95f5361c517c1367972: -------------------------------------------------------------------------------- 1 | haproxy_server_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c130c49a713919458f4c586807cbf6e9: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | speedtest_download [10m] 4 | ) < 100 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/c18b95980e52ce2426273b28f3039253: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:clientrequest:write:unavailables:count" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/c224a41ec9dbd85830916df009733744: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | pg_stat_database_deadlocks 4 | { 5 | datname!~"template.*|postgres" 6 | } [1m] 7 | ) > 5 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/c29cfee76c45b91a002a2dce4c72b8a8: -------------------------------------------------------------------------------- 1 | windows_exporter_collector_success == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c2f0da4b728875b3394f40aad342397e: -------------------------------------------------------------------------------- 1 | cortex_prometheus_notifications_alertmanagers_discovered < 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c2fe6f025500507f8389b95b3bb5e46f: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:metrics:storage:totalhints:count" 6 | } [1m] 7 | ) > 3 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/c40cd4337357fd546d99582770de2600: -------------------------------------------------------------------------------- 1 | kube_daemonset_status_number_misscheduled > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c5072f05fa3c2660136c8c6c40f6bda1: -------------------------------------------------------------------------------- 1 | kube_persistentvolumeclaim_status_phase 2 | { 3 | phase="Pending" 4 | } == 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/c5320e92b75ce794929d311de0041b73: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | etcd_server_proposals_failed_total [1h] 4 | ) > 5 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/c59ac9edc9de4049936316c7eb27fc54: -------------------------------------------------------------------------------- 1 | nomad_nomad_job_summary_lost > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c5c46cc255bdf599fdd44371c967458d: -------------------------------------------------------------------------------- 1 | elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes * 100 < 20 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c61db23d4d9de4c0aa379a645683090e: -------------------------------------------------------------------------------- 1 | kube_node_status_condition 2 | { 3 | condition="DiskPressure", 4 | status="true" 5 | } == 1 6 | -------------------------------------------------------------------------------- /tests/resources/formatted/c68077f5a896fc7993ff1c3aa353fd00: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | alertmanager_notifications_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/c680db12f24219bf009779b2e4dee29c: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_initializing_shards > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/c71ce9af681d5abbe9d67103bcc17007: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | job 4 | ) 5 | ( 6 | cortex_query_frontend_queue_length 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/c99310bef08a8927d4929f3caf8049cd: -------------------------------------------------------------------------------- 1 | prometheus_rule_group_last_duration_seconds > prometheus_rule_group_interval_seconds 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/ca648bf4b562274db6b2d57c4dc7e0d8: -------------------------------------------------------------------------------- 1 | ( 2 | 1 - ( 3 | sum 4 | ( 5 | container_fs_inodes_free 6 | { 7 | name!="" 8 | } 9 | ) 10 | BY 11 | ( 12 | instance 13 | ) / sum 14 | ( 15 | container_fs_inodes_total 16 | ) 17 | BY 18 | ( 19 | instance 20 | ) 21 | ) 22 | ) * 100 > 80 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/cd0ecb3b10cbe8af7e8e311c21171256: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_compactions_failed_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/cd853711f85e687e6032d40c922bbc80: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | cassandra_stats 4 | { 5 | name="org:apache:cassandra:net:failuredetector:downendpointcount" 6 | } 7 | ) 8 | by 9 | ( 10 | service, 11 | group, 12 | cluster, 13 | env 14 | ) > 0 15 | -------------------------------------------------------------------------------- /tests/resources/formatted/cda95bdae80688bd431f004c90712e58: -------------------------------------------------------------------------------- 1 | histogram_quantile 2 | ( 3 | 0.99, 4 | rate 5 | ( 6 | etcd_disk_backend_commit_duration_seconds_bucket [1m] 7 | ) 8 | ) > 0.25 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/cdb460a9b0eaed7ef1e7bfb689451002: -------------------------------------------------------------------------------- 1 | sidekiq_queue_size > 100 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/cdfe2c5a42ad8c7f213a6c9b21236e26: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_storage_size > 20 * 1024 * 1024 * 1024 4 | ) 5 | by 6 | ( 7 | topic 8 | ) 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/ce0166cfdf4ab11383df371b6a84f5fa: -------------------------------------------------------------------------------- 1 | cassandra_thread_pool_blocked_tasks 2 | { 3 | pool="MemtableFlushWriter" 4 | } > 15 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/ce0e4a708f795076f5b24a658a74f969: -------------------------------------------------------------------------------- 1 | avg 2 | ( 3 | cassandra_client_request_timeouts_total 4 | ) 5 | by 6 | ( 7 | cassandra_cluster, 8 | instance 9 | ) > 5 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/ce7b828a9483425d14901743bc22a9dd: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_storage_write_latency_overflow > 0 4 | ) 5 | by 6 | ( 7 | topic 8 | ) 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/ceefb547647c637dfb96f3428220bb69: -------------------------------------------------------------------------------- 1 | minio_disks_offline > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/cf9fd4966ae2703f7a9c2a2ed5b0fa69: -------------------------------------------------------------------------------- 1 | kube_job_status_failed > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/d06bce5e0785af0f7b9445afbb7b65c7: -------------------------------------------------------------------------------- 1 | ( 2 | elasticsearch_jvm_memory_used_bytes 3 | { 4 | area="heap" 5 | } / elasticsearch_jvm_memory_max_bytes 6 | { 7 | area="heap" 8 | } 9 | ) * 100 > 80 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/d0a6c1da3b091f4f7bb6793e07246638: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | junos_interface_transmit_bytes [1m] 4 | ) * 8 > 1e+9 * 0.80 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/d5dcbae6cf9612931d703b2924d69ea3: -------------------------------------------------------------------------------- 1 | rabbitmq_queue_consumers 2 | { 3 | queue="my-queue" 4 | } > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/d60e9e653386887e98209907bbcb8cc2: -------------------------------------------------------------------------------- 1 | cassandra_thread_pool_blocked_tasks 2 | { 3 | pool="CompactionExecutor" 4 | } > 15 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/d6c9e25c18dded5148fe00f7aa424f45: -------------------------------------------------------------------------------- 1 | redis_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/d75252fef4c4ddeba2dea39d209dd259: -------------------------------------------------------------------------------- 1 | min_over_time 2 | ( 3 | prometheus_notifications_queue_length [10m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/d79291b7bb444334b49556cc8008e2cd: -------------------------------------------------------------------------------- 1 | ( 2 | time 3 | ( 4 | ) - vmware_vm_snapshot_timestamp_seconds 5 | ) / ( 6 | 60 * 60 * 24 7 | ) >= 3 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/d90323737864ff187b57ab3d1bb6199f: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | prometheus_tsdb_wal_corruptions_total [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/d951dfb4a6c237f5a70f216400e9efa5: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum by 4 | ( 5 | proxy 6 | ) 7 | ( 8 | rate 9 | ( 10 | haproxy_server_http_responses_total 11 | { 12 | code="5xx" 13 | } [1m] 14 | ) 15 | ) / sum by 16 | ( 17 | proxy 18 | ) 19 | ( 20 | rate 21 | ( 22 | haproxy_server_http_responses_total [1m] 23 | ) 24 | ) 25 | ) * 100 26 | ) > 5 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/d9d951f18d9edf763933c947d438b9b1: -------------------------------------------------------------------------------- 1 | vmware_vm_mem_usage_average / 100 >= 90 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/da56c23c90c4f08deb733ea1a0258ca7: -------------------------------------------------------------------------------- 1 | netdata_md_mismatch_cnt_unsynchronized_blocks_average > 1024 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/db09ea1cfc170707558f3d988193600c: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | rabbitmq_exchange_messages_published_in_total 4 | { 5 | exchange="my-exchange" 6 | } [1m] 7 | ) < 5 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/db15895cdc51bd24b7baf38abe9bc8f4: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rabbitmq_queue_messages_unacked 4 | ) 5 | BY 6 | ( 7 | queue 8 | ) > 1000 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/db62142fa6dab8d55c4b93352f0d6280: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | zk_server_leader 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/db6febbf355f40b97cbfba0415625cb3: -------------------------------------------------------------------------------- 1 | rabbitmq_queue_messages 2 | { 3 | queue="my-dead-letter-queue" 4 | } > 10 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/dbb46029d17e8cba9a5899608fb97e29: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rate 4 | ( 5 | traefik_service_requests_total 6 | { 7 | code=~"4.*" 8 | } [3m] 9 | ) 10 | ) 11 | by 12 | ( 13 | service 14 | ) / sum 15 | ( 16 | rate 17 | ( 18 | traefik_service_requests_total [3m] 19 | ) 20 | ) 21 | by 22 | ( 23 | service 24 | ) * 100 > 5 25 | -------------------------------------------------------------------------------- /tests/resources/formatted/dc099882a652e0d00d98a6b15ab8fb38: -------------------------------------------------------------------------------- 1 | vector 2 | ( 3 | 1 4 | ) 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/dc3be75bb27787f5e96c15ac2b148f8f: -------------------------------------------------------------------------------- 1 | apiserver_client_certificate_expiration_seconds_count 2 | { 3 | job="apiserver" 4 | } > 0 and histogram_quantile 5 | ( 6 | 0.01, 7 | sum by 8 | ( 9 | job, 10 | le 11 | ) 12 | ( 13 | rate 14 | ( 15 | apiserver_client_certificate_expiration_seconds_bucket 16 | { 17 | job="apiserver" 18 | } [5m] 19 | ) 20 | ) 21 | ) < 7 * 24 * 60 * 60 22 | -------------------------------------------------------------------------------- /tests/resources/formatted/ddfdcebc8695d241c3bce32538860ed8: -------------------------------------------------------------------------------- 1 | mysql_slave_status_master_server_id > 0 and ON 2 | ( 3 | instance 4 | ) 5 | ( 6 | mysql_slave_status_seconds_behind_master - mysql_slave_status_sql_delay 7 | ) > 30 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/de1ac4b6db5c8081b6b5d474713e1ffa: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_storage_size > 5 * 1024 * 1024 * 1024 4 | ) 5 | by 6 | ( 7 | topic 8 | ) 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/dec48484b82b527578e2bcbf5690112e: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | rabbitmq_build_info 4 | ) < 3 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/decddbb210958457fdf8cccd04516650: -------------------------------------------------------------------------------- 1 | max_over_time 2 | ( 3 | mysql_global_status_threads_running [1m] 4 | ) / mysql_global_variables_max_connections * 100 > 60 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/dfae391e4e2766909ca99f2fb12ea73f: -------------------------------------------------------------------------------- 1 | delta 2 | ( 3 | jenkins_runs_failure_total [1h] 4 | ) > 100 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/e092b52b7c7d999cb3ff5d6025c196cf: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | server 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_connection_errors_total [1m] 9 | ) 10 | ) > 100 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/e25625038a40ea52e468a887e7cd948a: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | cassandra_client_request_failures_total 4 | { 5 | operation="write" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/e309dcb5d5f79d76f87fe2ce747bb38a: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | datname 4 | ) 5 | ( 6 | pg_stat_activity_count 7 | { 8 | datname!~"template.*|postgres" 9 | } 10 | ) > pg_settings_max_connections * 0.8 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/e31b0a25e89d8c728b4d6e88ae6bee35: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | server 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_server_response_errors_total [1m] 9 | ) 10 | ) / sum by 11 | ( 12 | server 13 | ) 14 | ( 15 | rate 16 | ( 17 | haproxy_server_http_responses_total [1m] 18 | ) * 100 19 | ) > 5 20 | -------------------------------------------------------------------------------- /tests/resources/formatted/e3e320bb6fbd7bbb9e9336f4700c8edb: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_initializing_shards > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/e40b031ea2afaa9924fe212154c1e543: -------------------------------------------------------------------------------- 1 | ( 2 | elasticsearch_jvm_memory_used_bytes 3 | { 4 | area="heap" 5 | } / elasticsearch_jvm_memory_max_bytes 6 | { 7 | area="heap" 8 | } 9 | ) * 100 > 90 10 | -------------------------------------------------------------------------------- /tests/resources/formatted/e52c473ae3a6e1a50e0c594ea43ebaad: -------------------------------------------------------------------------------- 1 | ( 2 | pg_stat_user_tables_last_autovacuum > 0 3 | ) and ( 4 | time 5 | ( 6 | ) - pg_stat_user_tables_last_autovacuum 7 | ) > 60 * 60 * 24 * 10 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/e57472bb2de637d387e9d4a3293afec6: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | pulsar_subscription_back_log 4 | ) 5 | by 6 | ( 7 | subscription 8 | ) > 100000 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/e5ef1732a53ee1bbbec01e3febca1d48: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | node_vmstat_oom_kill [1m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/e66d83876537e69b7db09380f9c8b901: -------------------------------------------------------------------------------- 1 | kube_job_spec_completions - kube_job_status_succeeded > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/e688b8853a0e32c6d1072f0e814772b9: -------------------------------------------------------------------------------- 1 | 100.0 - 100 * ( 2 | ( 3 | windows_logical_disk_free_bytes / 1024 / 1024 4 | ) / ( 5 | windows_logical_disk_size_bytes / 1024 / 1024 6 | ) 7 | ) > 80 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/e6b30c046d75fb12e23fa9443bf18039: -------------------------------------------------------------------------------- 1 | nomad_nomad_blocked_evals_total_blocked > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/e8253900e7cecf5e77b26795e8b2a7e6: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | process_start_time_seconds 4 | { 5 | job=~"loki" 6 | } [15m] 7 | ) > 2 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/e8df893f9563a2a2caaa7269ce53f901: -------------------------------------------------------------------------------- 1 | zk_ruok == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/e99d62692d9ca0a6a874dfa82aa927c3: -------------------------------------------------------------------------------- 1 | kube_horizontalpodautoscaler_status_desired_replicas >= kube_horizontalpodautoscaler_spec_max_replicas 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/e9aa9df72dc5ec1d6582631ce11d3977: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | pg_replication_is_replica == 0 4 | ) != 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/e9afc761a80cc1fd38aa240880f8863c: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | proxy 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_backend_retry_warnings_total [1m] 9 | ) 10 | ) > 10 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/ea4a4c06999bc333751f7a3f8e315146: -------------------------------------------------------------------------------- 1 | rate 2 | ( 3 | cortex_prometheus_notifications_dropped_total [5m] 4 | ) > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/ec2a5b91683efdaf72ab17d4845d8f87: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum by 4 | ( 5 | proxy 6 | ) 7 | ( 8 | rate 9 | ( 10 | haproxy_server_http_responses_total 11 | { 12 | code="4xx" 13 | } [1m] 14 | ) 15 | ) / sum by 16 | ( 17 | proxy 18 | ) 19 | ( 20 | rate 21 | ( 22 | haproxy_server_http_responses_total [1m] 23 | ) 24 | ) 25 | ) * 100 26 | ) > 5 27 | -------------------------------------------------------------------------------- /tests/resources/formatted/ec8cff1591cc542e05b204025593f656: -------------------------------------------------------------------------------- 1 | node_md_state 2 | { 3 | state="inactive" 4 | } > 0 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/ed2a51c7efee7669109b5a87e998ed44: -------------------------------------------------------------------------------- 1 | predict_linear 2 | ( 3 | netdata_disk_space_GB_average 4 | { 5 | dimension=~"avail|cached" 6 | } [3h], 7 | 24 * 3600 8 | ) < 0 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/eff4a4b6422d673560424aeea3582786: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_client_request_unavailable_exceptions_total 4 | { 5 | operation="write" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/f0184be2bbfe3259325a06be28010772: -------------------------------------------------------------------------------- 1 | time 2 | ( 3 | ) - redis_rdb_last_save_timestamp_seconds > 60 * 60 * 24 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/f06cf46fdd11d488d2e2039b02ea0871: -------------------------------------------------------------------------------- 1 | mongodb_replset_member_state == 8 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f11e6309497859a9ff887bfdaef8163a: -------------------------------------------------------------------------------- 1 | count without 2 | ( 3 | instance, 4 | job 5 | ) 6 | ( 7 | redis_connected_slaves 8 | ) - sum without 9 | ( 10 | instance, 11 | job 12 | ) 13 | ( 14 | redis_connected_slaves 15 | ) - 1 > 1 16 | -------------------------------------------------------------------------------- /tests/resources/formatted/f17b8d8c71b408ecc8060e90ee14c3be: -------------------------------------------------------------------------------- 1 | count 2 | ( 3 | count_values 4 | ( 5 | "config_hash", 6 | alertmanager_config_hash 7 | ) 8 | ) > 1 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/f204ee584e3aff11a0643c59e14a5c67: -------------------------------------------------------------------------------- 1 | kube_cronjob_spec_suspend != 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f2765d469cf1845ca5c9ffcc650008ff: -------------------------------------------------------------------------------- 1 | freeswitch_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f301d782da751c3be89cae7bf64d2971: -------------------------------------------------------------------------------- 1 | elasticsearch_cluster_health_relocating_shards > 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f35436ba635651d244fe7e997d39b1a3: -------------------------------------------------------------------------------- 1 | thanos_compact_halted == 1 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f3b2891f3b61bda3948454e27093b460: -------------------------------------------------------------------------------- 1 | up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f453abb5459a544765acb371095a7eca: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | mgob_scheduler_backup_total 4 | { 5 | status="500" 6 | } [1h] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/f57d8229808c14b35d4d9da4b7b5083c: -------------------------------------------------------------------------------- 1 | mssql_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f691df6701a5ffcb7aa95084c8eaa0c2: -------------------------------------------------------------------------------- 1 | vault_core_unsealed == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f73e4781909f47a243d477a9321b9cba: -------------------------------------------------------------------------------- 1 | haproxy_up == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/f7bfdfcad7a3b1dfb4786440cb71762c: -------------------------------------------------------------------------------- 1 | avg_over_time 2 | ( 3 | probe_icmp_duration_seconds [1m] 4 | ) > 1 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/f8862f7330d14c8e28274c4ebe3f073c: -------------------------------------------------------------------------------- 1 | ( 2 | kube_statefulset_status_replicas_ready / kube_statefulset_status_replicas_current 3 | ) != 1 4 | -------------------------------------------------------------------------------- /tests/resources/formatted/f8e6781ccccdcb7b15d279b9758e28f7: -------------------------------------------------------------------------------- 1 | increase 2 | ( 3 | rabbitmq_channel_messages_unroutable_returned_total [1m] 4 | ) > 0 or increase 5 | ( 6 | rabbitmq_channel_messages_unroutable_dropped_total [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/f8fc21146e4f72712b52b46e59b54d34: -------------------------------------------------------------------------------- 1 | avg by 2 | ( 3 | proxy 4 | ) 5 | ( 6 | haproxy_backend_max_total_time_seconds 7 | ) > 1 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/fa04700d4bc421e5ac39d59a219d34c2: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | job 4 | ) 5 | ( 6 | up 7 | ) == 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/fb8fabc9c08bad5ec9784da518794f19: -------------------------------------------------------------------------------- 1 | sum by 2 | ( 3 | backend 4 | ) 5 | ( 6 | rate 7 | ( 8 | haproxy_backend_connection_errors_total [1m] 9 | ) 10 | ) > 100 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/fc80f82dbd1483ab989b1f8284f60f03: -------------------------------------------------------------------------------- 1 | cassandra_commit_log_pending_tasks > 15 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/fc8634d969c2b3a047e7af0eacd61036: -------------------------------------------------------------------------------- 1 | ( 2 | sum 3 | ( 4 | container_memory_working_set_bytes 5 | { 6 | name!="" 7 | } 8 | ) 9 | BY 10 | ( 11 | instance, 12 | name 13 | ) / sum 14 | ( 15 | container_spec_memory_limit_bytes > 0 16 | ) 17 | BY 18 | ( 19 | instance, 20 | name 21 | ) * 100 22 | ) > 80 23 | -------------------------------------------------------------------------------- /tests/resources/formatted/fca38b562ed8eb98cef1da50a09ba96b: -------------------------------------------------------------------------------- 1 | changes 2 | ( 3 | cassandra_client_request_unavailable_exceptions_total 4 | { 5 | operation="read" 6 | } [1m] 7 | ) > 0 8 | -------------------------------------------------------------------------------- /tests/resources/formatted/fd830ec0bcb69a1c1c25c6b3b977d1b0: -------------------------------------------------------------------------------- 1 | default_jenkins_builds_last_build_result_ordinal == 2 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/fe1c959498ad2436d8255602c936c5f8: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | pg_stat_user_tables_n_dead_tup > 10000 4 | ) / ( 5 | pg_stat_user_tables_n_live_tup + pg_stat_user_tables_n_dead_tup 6 | ) 7 | ) >= 0.1 unless ON 8 | ( 9 | instance 10 | ) 11 | ( 12 | pg_replication_is_replica == 1 13 | ) 14 | -------------------------------------------------------------------------------- /tests/resources/formatted/fe4cee76605b020eab65bd9ff50a4f7c: -------------------------------------------------------------------------------- 1 | prometheus_sd_discovered_targets == 0 2 | -------------------------------------------------------------------------------- /tests/resources/formatted/fe9fe63e9fd686663f8740c3c7b3b8e9: -------------------------------------------------------------------------------- 1 | sum 2 | ( 3 | jenkins_plugins_withUpdate 4 | ) 5 | by 6 | ( 7 | instance 8 | ) > 3 9 | -------------------------------------------------------------------------------- /tests/resources/formatted/fea4da1497af1d3a767699fa5fd7a40c: -------------------------------------------------------------------------------- 1 | ( 2 | ( 3 | sum 4 | ( 5 | pg_locks_count 6 | ) 7 | ) / ( 8 | pg_settings_max_locks_per_transaction * pg_settings_max_connections 9 | ) 10 | ) > 0.20 11 | -------------------------------------------------------------------------------- /tests/resources/formatted/ff8dbd7076ae267a40d513c1bfa3adbe: -------------------------------------------------------------------------------- 1 | rabbitmq_queue_messages_ready 2 | { 3 | queue="my-queue" 4 | } > 1000 5 | -------------------------------------------------------------------------------- /tests/resources/formatted/ffcc296b9a80279494dba16ec6491aa6: -------------------------------------------------------------------------------- 1 | rabbitmq_queue_consumers == 0 2 | -------------------------------------------------------------------------------- /tests/test_formatter.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | import antlr4 4 | import pkg_resources 5 | import yaml 6 | import pytest 7 | from antlr4 import CommonTokenStream 8 | 9 | from promformat import _build_cst 10 | 11 | import hashlib 12 | import os 13 | 14 | import pkg_resources 15 | import yaml 16 | import pytest 17 | 18 | from promformat.__main__ import format_query 19 | from promformat.parser.PromQLParserListener import PromQLParserListener 20 | 21 | 22 | def get_rules(): 23 | rule_path = pkg_resources.resource_filename("tests.resources", "test-promql.yaml") 24 | with open(rule_path) as f: 25 | data = yaml.safe_load(f) 26 | for group in data["groups"]: 27 | for service in group["services"]: 28 | for exporter in service["exporters"]: 29 | rules = exporter.get("rules") 30 | if rules: 31 | for rule in rules: 32 | hasher = hashlib.md5() 33 | hasher.update(rule["query"].encode("utf-8")) 34 | hasher.update(group["name"].encode("utf-8")) 35 | hasher.update(service["name"].encode("utf-8")) 36 | hasher.update(rule["name"].encode("utf-8")) 37 | yield dict( 38 | group=group.get("name", "unnamed group"), 39 | service=service.get("name", "unnamed service"), 40 | exporter=exporter.get("name", "unnamed exporter"), 41 | rule=rule.get("name", "unnamed rule"), 42 | filename=hasher.hexdigest(), 43 | query=rule["query"], 44 | ) 45 | 46 | 47 | @pytest.mark.parametrize( 48 | ["query"], 49 | [ 50 | pytest.param(rule["query"], id="{service}/{exporter}/{rule}".format(**rule)) 51 | for rule in get_rules() 52 | ], 53 | ) 54 | def test_formatter(query): 55 | assert format_query(query) 56 | 57 | 58 | class CommentListener(PromQLParserListener): 59 | def __init__(self): 60 | self.has_comments = False 61 | self.comment_contexts = [] 62 | 63 | def exitEveryRule(self, ctx): 64 | if self._extract_comments_from_context(ctx) is not None: 65 | self.has_comments = True 66 | self.comment_contexts.append(ctx) 67 | 68 | def _extract_comments_from_context(self, ctx): 69 | stream: CommonTokenStream = ctx.parser.getInputStream() 70 | index = ctx.start.tokenIndex 71 | comment_tokens = stream.getHiddenTokensToLeft(index, channel=3) 72 | if comment_tokens: 73 | return [c.text.strip() for c in comment_tokens] 74 | 75 | 76 | @pytest.mark.parametrize( 77 | ["query"], 78 | [ 79 | pytest.param(rule["query"], id="{service}/{exporter}/{rule}".format(**rule)) 80 | for rule in get_rules() 81 | ], 82 | ) 83 | def test_comments(query: str): 84 | comment = "\n# I am comment\n" 85 | query_parts = query.split() 86 | # Admittedly not the greatest approach, but if you 87 | # run it long enough it finds a lot of bugs. 88 | index = randint(0, len(query_parts) - 1) 89 | query_parts.insert(index, comment) 90 | new_query = " ".join(query_parts) 91 | 92 | parse_tree = _build_cst(new_query) 93 | listener = CommentListener() 94 | walker = antlr4.ParseTreeWalker() 95 | walker.walk(listener, parse_tree) 96 | # Sometimes the parse tree doesn't even 97 | # contain the comments so nothing we 98 | # can do. 99 | if not listener.has_comments: 100 | return 101 | 102 | formatted = format_query(new_query) 103 | assert ( 104 | formatted.count("I am comment") == 1 105 | ), f"{new_query}: {listener.comment_contexts}" 106 | 107 | 108 | @pytest.mark.parametrize( 109 | ["query", "file_name"], 110 | [ 111 | pytest.param( 112 | rule["query"], 113 | rule["filename"], 114 | id="{service}/{exporter}/{rule}".format(**rule), 115 | ) 116 | for rule in get_rules() 117 | ], 118 | ) 119 | def test_formatter(query, file_name): 120 | rule_path = pkg_resources.resource_filename("tests.resources", "formatted") 121 | path = os.path.join(rule_path, file_name) 122 | with open(path) as f: 123 | expected_formatting = f.read() 124 | assert format_query(query) == expected_formatting 125 | --------------------------------------------------------------------------------