Regex buddy
Author: m | 2025-04-24
Free Downloads: Regex Buddy. License: All 1 2 Regular Expressions Online Tester; Regex Buddy; Regex 101 (for PCRE, JavaScript, Python, Golang, Java 8) I Hate Regex; Visual RegExp; Expresso (for .NET)
URL regex passed by regex buddy but failed by Dart
Fill PDF Online Fill out online for free without registration or credit card A Regex Cheat Sheet is a quick reference guide that provides information about regular expressions. It helps people to quickly recall and understand the syntax and special characters used in regular expressions for pattern matching and text manipulation.FAQQ: What is a regex?A: A regex, short for regular expression, is a sequence of characters that forms a search pattern.Q: What can regex be used for?A: Regex can be used for pattern matching, search and replace operations, and input validation.Q: How do I use regex?A: You can use regex by writing a pattern and searching for matches within a string using functions provided by a programming language or text editor.Q: What are some common regex metacharacters?A: Some common metacharacters in regex include . (dot), ^ (caret), $ (dollar sign), * (asterisk), + (plus), ? (question mark), and \ (backslash).Q: What is the dot metacharacter in regex?A: The dot metacharacter matches any single character except a newline character.Q: What is the caret metacharacter in regex?A: The caret metacharacter matches the start of a string or the start of a line, depending on the regex mode.Q: What is the dollar sign metacharacter in regex?A: The dollar sign metacharacter matches the end of a string or the end of a line, depending on the regex mode.Q: What is the asterisk metacharacter in regex?A: The asterisk metacharacter matches zero or more occurrences of the preceding character or group.Q: What is the plus metacharacter in regex?A: The plus metacharacter matches one or more occurrences of the preceding character or group.Q: What is the question mark metacharacter in regex?A: The question mark metacharacter matches zero or one occurrence of the preceding character or group.Q: What is the backslash metacharacter in regex?A: The backslash metacharacter is used to escape special characters or to give them special meanings in regex. Download Regex Cheat Sheet
Do any of the flavors of regex in Regex Buddy coincide with
What's wrong?I have several drop rules in discovery.relabel "kubernetes_nodes", but only the first one appears to drop the metric.Steps to reproduceDeploy alloy helm chart 0.7.0send metrics to prometheus with several drop rulesExpected result: all metrics specified in drop rules droppedActual result: only the metric in the first drop rule droppedSystem informationUbuntu 23.10Software version1.3.1ConfigurationValues passed to helm chart:file1:alloy: enabled: false alloy: clustering: enabled: true enableReporting: false resources: limits: cpu: 4 memory: 30Gi requests: cpu: 2 memory: 30Gi rbac: create: true controller: type: 'statefulset' replicas: 2 enableStatefulSetAutoDeletePVC: true autoscaling: enabled: true minReplicas: 2 maxReplicas: 10 targetMemoryUtilizationPercentage: 60 scaleUp: policies: - type: Pods value: 2 periodSeconds: 60file2:alloy: enabled: true alloy: configMap: create: true content: |- discovery.kubernetes "kubernetes_nodes" { role = "node" } discovery.kubernetes "kubernetes_nodes_cadvisor" { role = "node" } discovery.kubernetes "kubernetes_service_endpoints" { role = "endpoints" } discovery.kubernetes "kubernetes_service_endpoints_slow" { role = "endpoints" } discovery.kubernetes "kubernetes_services" { role = "service" } discovery.kubernetes "kubernetes_pods" { role = "pod" } discovery.kubernetes "kubernetes_pods_slow" { role = "pod" } discovery.relabel "kubernetes_nodes" { targets = discovery.kubernetes.kubernetes_nodes.targets rule { source_labels = ["__name__"] regex = "(kubelet_runtime_duration_seconds_bucket)" action = "drop" } rule { source_labels = ["__name__"] regex = "(kubelet_http_requests_duration_seconds_bucket)" action = "drop" } rule { source_labels = ["__name__"] regex = "(kubernetes_feature_enabled)" action = "drop" } rule { regex = "__meta_kubernetes_node_label_(.+)" action = "labelmap" } rule { target_label = "__address__" replacement = "kubernetes.default.svc:443" } rule { source_labels = ["__meta_kubernetes_node_name"] regex = "(.+)" target_label = "__metrics_path__" replacement = "/api/v1/nodes/$1/proxy/metrics" } } discovery.relabel "kubernetes_nodes_cadvisor" { targets = discovery.kubernetes.kubernetes_nodes_cadvisor.targets rule { regex = "__meta_kubernetes_node_label_(.+)" action = "labelmap" } rule { target_label = "__address__" replacement = "kubernetes.default.svc:443" } rule { source_labels = ["__meta_kubernetes_node_name"] regex = "(.+)" target_label = "__metrics_path__" replacement = "/api/v1/nodes/$1/proxy/metrics/cadvisor" } } discovery.relabel "kubernetes_service_endpoints" { targets = discovery.kubernetes.kubernetes_service_endpoints.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape_slow"] regex = "true" action = "drop" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__address__", "__meta_kubernetes_service_annotation_prometheus_io_port"] regex = "(.+?)(?::\\d+)?;(\\d+)" target_label = "__address__" replacement = "$1:$2" } rule { regex = "__meta_kubernetes_service_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } discovery.relabel "kubernetes_service_endpoints_slow" { targets = discovery.kubernetes.kubernetes_service_endpoints_slow.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape_slow"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__address__", "__meta_kubernetes_service_annotation_prometheus_io_port"] regex = "(.+?)(?::\\d+)?;(\\d+)" target_label = "__address__" replacement = "$1:$2" } rule { regex = "__meta_kubernetes_service_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label =@foxxmd/regex-buddy-core Docs
Are now treated as errors in Helpful mode; the actual behavior of GNU ERE is still emulated in Strict mode. Create: Empty alternatives inside a group or a conditional now have a node indicating that empty alternatives find zero-length matches. History: Different icon for the Clear button which erases the history, unlike the New button on the Library toolbar which starts a new library without deleting the previous library. Bug fixes: Copy/Use: Regular expressions and replacement strings that did not contain backslashes or line breaks were not correctly formatted as C# strings (4.2.0 only). Create: Combined quantifiers like .*? in GNU ERE had their nodes on the Create panel in reverse order. Debug: Debugging a regular expression sometimes failed with a “division by zero” error. Library: If a library entry somehow ended up with a blank regex then selecting that blank entry in the library could cause errors. Library: Update button allowed a regex in the library to be replaced with a blank regex; now the Update button is disabled when there is no current regex, just like the Add button is disabled then. Use: String literals with the regex tree had an extra concatenation operator at the end if the application does not support multi-line strings or free-spacing regexes and if the regex tree ended with warning nodes that aren’t linked to a part of the regex. See also: RegexBuddy 4.2.1 release notes RegexBuddy 4.2.0 – 7 October 2014 New features: Applications: Delphi and C++Builder XE7. Applications: Perl 5.20. Applications: Visual C++ and C++Builder (Win64) using std::regex. Aspects: \p{Any}, \p{All}, \p{Assigned}, and \p{Unicode} with or without “Is” prefix. Aspects: Newline may be an alternation operator. Aspects: POSIX collation names for ASCII characters. Aspects: Shorthand character classes using POSIX character class notation [[:d:][:s:][:w:]]. Convert: Flavor choice for applications that offer multiple regex syntax choices in a single library, allowing you to convert the regex to any of the syntax choices offered by the application; presently this is only used for std::regex. Options: Flavor choice for applications that offer multiple regex syntax choices in a single library; presently this is only used for std::regex and allows us to have one entry for std::regex and one for std::wregex for each version of Visual C++ or C++Builder, instead of having 6 separate entries for the 6 different regex flavors for every version of std::regex and std::wregex. Test: Keyboard shortcuts for going to the next (Alt+N) and previous (Alt+P) highlighted match, and for going to the first (Alt+F) and next (Alt+N) match when matches are not highlighted. Improvements: Applications: Opera applications now use Chrome flavors as Opera is now based on the WebKit engine used by Chrome meaning the two now have identical regex flavors; Opera flavors have been removed. Applications: PHP version numbers updated through 5.6.1 (no changes to regex flavors). Applications: R version number updated to 3.1.1 (no changes to regex flavor). Applications: Regex syntax that makes Perl print deprecation warnings is now treated as an error by the Perl flavors in. Free Downloads: Regex Buddy. License: All 1 2Regex Buddy - Muffin Research Labs
"node" } } discovery.relabel "kubernetes_services" { targets = discovery.kubernetes.kubernetes_services.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_probe"] regex = "true" action = "keep" } rule { source_labels = ["__address__"] target_label = "__param_target" } rule { target_label = "__address__" replacement = "blackbox" } rule { source_labels = ["__param_target"] target_label = "instance" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } } discovery.relabel "kubernetes_pods" { targets = discovery.kubernetes.kubernetes_pods.targets rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape_slow"] regex = "true" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})" target_label = "__address__" replacement = "[$2]:$1" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);((([0-9]+?)(\\.|$)){4})" target_label = "__address__" replacement = "$2:$1" } rule { regex = "__meta_kubernetes_pod_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_pod_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_pod_name"] target_label = "pod" } rule { source_labels = ["__meta_kubernetes_pod_phase"] regex = "Pending|Succeeded|Failed|Completed" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } discovery.relabel "kubernetes_pods_slow" { targets = discovery.kubernetes.kubernetes_pods_slow.targets rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape_slow"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})" target_label = "__address__" replacement = "[$2]:$1" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);((([0-9]+?)(\\.|$)){4})" target_label = "__address__" replacement = "$2:$1" } rule { regex = "__meta_kubernetes_pod_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_pod_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_pod_name"] target_label = "pod" } rule { source_labels = ["__meta_kubernetes_pod_phase"] regex = "Pending|Succeeded|Failed|Completed" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } prometheus.scrape "prometheus" { targets = [{ __address__ = "localhost:9090", }] forward_to = [prometheus.remote_write.default.receiver] job_name = "prometheus" clustering { enabled = true } } prometheus.scrape "kubernetes_nodes" { targets = discovery.relabel.kubernetes_nodes.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-nodes" scheme = "https" authorization { type = "Bearer" credentials_file = "/var/run/secrets/kubernetes.io/serviceaccount/token" } tls_config { ca_file = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" insecure_skip_verify = true } clustering { enabled = true } } prometheus.scrape "kubernetes_nodes_cadvisor" { targets = discovery.relabel.kubernetes_nodes_cadvisor.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-nodes-cadvisor" scheme = "https" authorization { type = "Bearer" credentials_file = "/var/run/secrets/kubernetes.io/serviceaccount/token" } tls_config { ca_file = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" insecure_skip_verify = true } clustering { enabled = true } } prometheus.scrape "kubernetes_service_endpoints" { targets = discovery.relabel.kubernetes_service_endpoints.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-service-endpoints" honor_labels = true clustering { enabled = true } } prometheus.scrape "kubernetes_service_endpoints_slow" { targets = discovery.relabel.kubernetes_service_endpoints_slow.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-service-endpoints-slow" honor_labels = true scrape_interval =Regex Buddy - Free Software Downloads and Reviews
Regex Books and Resources This page contains two main sections:✽ Regex Books✽ Online Regex Resources(direct link)Of the four books about regular expressions I have seen, two O'Reilly books are well worth reading. They are different, and if you fall in love with regex, you will probably want to read both. The one to start with is Jan's Regular Expressions Cookbook. The first two chapters give you a quick ramp-up to regular expressions. The third chapter shows you how to perform a number of regex operations in various programming languages. (If you use RB, you may recognize the kind of code output by the Use panel.) In cookbook fashion, the remaining five chapters present recipes for many of the tasks you might want to accomplish with regex. If you use RegexBuddy, you will see a parallel between the choice of recipes and the patterns in the RB library. Eventually, the book you will want to study is Jeffrey Friedl's Mastering Regex Expressions. The first three chapters make a solid introduction to regex. Chapters 4 and 5 are excellent reads about advanced regex. Chapter 6 contains a fascinating discussion of techniques to optimize your expressions. The four remaining chapters each focus on using regular expressions in a particular context: Perl, .NET, Java and PHP.O'Reilly also has a Regular Expression Pocket Reference which I find uninteresting.If you have read this site (or Jan's tutorial), Sams Teach Yourself Regular Expressions in 10 Minutes is a waste of time. (direct link)Online Regex ResourcesRegex Engine Benchmark. I'll put that first because I find it fascinating: regex-redux regex engine benchmark..NET regex contact at Microsoft?. Bookmarking this post from Dan Moseley just in case.JG SoftIn the world of regex-ware, there is one name to remember: JGSoft, or the man behind it, Jan Goyvaerts. You might think that JGSoft stands for "Jan Goyvaerts Software"—but no, it stands for "Just Great Software". Jan seems to have infiltrated the world of regex to its very core. He stands behind:- a top-notch online regex tutorial- a regex engine (JGSoft)- a top text editor (EditPad Pro) that uses the JGSoft regex engine- veryRegex buddy - Misc snippets - Coders-Resources
Ends with, does not end with Flexible contains check: contains at least N times, contains at most N times, contains exactly N times, contains between N and M times, contains but not N times. Support for wildcard character matching with * Case-insensitive search with Ignore Case optionRestrict search range to either specified character or line range, like "search only within last 50 lines"Support for RegEx-style character escapes: \x9E, \080, \u12ABMultiple Text Content Condition Check if the file contains or does not contain specified number of items from the list, or if it starts/ends with or does not start/end with any of them. This condition is useful if you want to make sure a file contains certain minimum number of specific text patterns. 6 types of checks: contains, does not contain, start with, does not start with, ends with, does not end with Flexible contains check: contains all items, contains at least N items, contains at most N items, contains exactly N items, contains between N and M items, contains but not N items, does not contain any items. Support for wildcard character matching with * Case-insensitive search with Ignore Case option Support for RegEx-style character escapes: \x9E, \080, \u12AB List of items can be saved for future use to a text file Text items can be imported from a text file or pasted from clipboard Note that this condition does not let you specify precise counts for individual items.Condition Behavior Settings Every condition has these common behavior settings that determine how it interacts with other conditions and thus how it affects file processing flow. Condition may allow further processing either if the requirements / check specified by it are met or not met (i.e. if the result of checking the file against a constraint is either True or False). Condition group behavior determines whether the conditions add to each other (i.e. each condition in a group adds additional requirements — equivalent to logical AND, or if the processing should continue as long as at least one condition in a group will pass — equivalent to logical OR. In addition it is possible to compare conditions inside a group using logical XOR operator, and negate the entire condition check. Negation of a condition or a condition group result may be very useful, because some times it is easier to define the checks for the True case and not for the negated case. Full RegEx Support Excellent RegEx Support The program features excellent support for Regular Expressions in file processing tasks: 4 RegEx Actions: RegEx Replace, Multiple RegEx Replace, RegEx Extract, and RegEx Format 2 RegEx Conditions: RegEx Content and Multiple RegEx Content Replace supports RegEx substitutions and named or numbered groups 6 Built-in RegEx tools to help you design RegEx patterns: number selector, tag selector, line selector, etc. Complete syntax highlighting for all RegEx patterns Optional dynamic syntax tips for RegEx elements RegEx support in auxiliary operations: file searching, file renaming, etc. Various RegEx options: ignore case, multiline, single line, etc.. Free Downloads: Regex Buddy. License: All 1 2 Regular Expressions Online Tester; Regex Buddy; Regex 101 (for PCRE, JavaScript, Python, Golang, Java 8) I Hate Regex; Visual RegExp; Expresso (for .NET)Comments
Fill PDF Online Fill out online for free without registration or credit card A Regex Cheat Sheet is a quick reference guide that provides information about regular expressions. It helps people to quickly recall and understand the syntax and special characters used in regular expressions for pattern matching and text manipulation.FAQQ: What is a regex?A: A regex, short for regular expression, is a sequence of characters that forms a search pattern.Q: What can regex be used for?A: Regex can be used for pattern matching, search and replace operations, and input validation.Q: How do I use regex?A: You can use regex by writing a pattern and searching for matches within a string using functions provided by a programming language or text editor.Q: What are some common regex metacharacters?A: Some common metacharacters in regex include . (dot), ^ (caret), $ (dollar sign), * (asterisk), + (plus), ? (question mark), and \ (backslash).Q: What is the dot metacharacter in regex?A: The dot metacharacter matches any single character except a newline character.Q: What is the caret metacharacter in regex?A: The caret metacharacter matches the start of a string or the start of a line, depending on the regex mode.Q: What is the dollar sign metacharacter in regex?A: The dollar sign metacharacter matches the end of a string or the end of a line, depending on the regex mode.Q: What is the asterisk metacharacter in regex?A: The asterisk metacharacter matches zero or more occurrences of the preceding character or group.Q: What is the plus metacharacter in regex?A: The plus metacharacter matches one or more occurrences of the preceding character or group.Q: What is the question mark metacharacter in regex?A: The question mark metacharacter matches zero or one occurrence of the preceding character or group.Q: What is the backslash metacharacter in regex?A: The backslash metacharacter is used to escape special characters or to give them special meanings in regex. Download Regex Cheat Sheet
2025-04-24What's wrong?I have several drop rules in discovery.relabel "kubernetes_nodes", but only the first one appears to drop the metric.Steps to reproduceDeploy alloy helm chart 0.7.0send metrics to prometheus with several drop rulesExpected result: all metrics specified in drop rules droppedActual result: only the metric in the first drop rule droppedSystem informationUbuntu 23.10Software version1.3.1ConfigurationValues passed to helm chart:file1:alloy: enabled: false alloy: clustering: enabled: true enableReporting: false resources: limits: cpu: 4 memory: 30Gi requests: cpu: 2 memory: 30Gi rbac: create: true controller: type: 'statefulset' replicas: 2 enableStatefulSetAutoDeletePVC: true autoscaling: enabled: true minReplicas: 2 maxReplicas: 10 targetMemoryUtilizationPercentage: 60 scaleUp: policies: - type: Pods value: 2 periodSeconds: 60file2:alloy: enabled: true alloy: configMap: create: true content: |- discovery.kubernetes "kubernetes_nodes" { role = "node" } discovery.kubernetes "kubernetes_nodes_cadvisor" { role = "node" } discovery.kubernetes "kubernetes_service_endpoints" { role = "endpoints" } discovery.kubernetes "kubernetes_service_endpoints_slow" { role = "endpoints" } discovery.kubernetes "kubernetes_services" { role = "service" } discovery.kubernetes "kubernetes_pods" { role = "pod" } discovery.kubernetes "kubernetes_pods_slow" { role = "pod" } discovery.relabel "kubernetes_nodes" { targets = discovery.kubernetes.kubernetes_nodes.targets rule { source_labels = ["__name__"] regex = "(kubelet_runtime_duration_seconds_bucket)" action = "drop" } rule { source_labels = ["__name__"] regex = "(kubelet_http_requests_duration_seconds_bucket)" action = "drop" } rule { source_labels = ["__name__"] regex = "(kubernetes_feature_enabled)" action = "drop" } rule { regex = "__meta_kubernetes_node_label_(.+)" action = "labelmap" } rule { target_label = "__address__" replacement = "kubernetes.default.svc:443" } rule { source_labels = ["__meta_kubernetes_node_name"] regex = "(.+)" target_label = "__metrics_path__" replacement = "/api/v1/nodes/$1/proxy/metrics" } } discovery.relabel "kubernetes_nodes_cadvisor" { targets = discovery.kubernetes.kubernetes_nodes_cadvisor.targets rule { regex = "__meta_kubernetes_node_label_(.+)" action = "labelmap" } rule { target_label = "__address__" replacement = "kubernetes.default.svc:443" } rule { source_labels = ["__meta_kubernetes_node_name"] regex = "(.+)" target_label = "__metrics_path__" replacement = "/api/v1/nodes/$1/proxy/metrics/cadvisor" } } discovery.relabel "kubernetes_service_endpoints" { targets = discovery.kubernetes.kubernetes_service_endpoints.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape_slow"] regex = "true" action = "drop" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__address__", "__meta_kubernetes_service_annotation_prometheus_io_port"] regex = "(.+?)(?::\\d+)?;(\\d+)" target_label = "__address__" replacement = "$1:$2" } rule { regex = "__meta_kubernetes_service_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } discovery.relabel "kubernetes_service_endpoints_slow" { targets = discovery.kubernetes.kubernetes_service_endpoints_slow.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scrape_slow"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__address__", "__meta_kubernetes_service_annotation_prometheus_io_port"] regex = "(.+?)(?::\\d+)?;(\\d+)" target_label = "__address__" replacement = "$1:$2" } rule { regex = "__meta_kubernetes_service_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label =
2025-04-10"node" } } discovery.relabel "kubernetes_services" { targets = discovery.kubernetes.kubernetes_services.targets rule { source_labels = ["__meta_kubernetes_service_annotation_prometheus_io_probe"] regex = "true" action = "keep" } rule { source_labels = ["__address__"] target_label = "__param_target" } rule { target_label = "__address__" replacement = "blackbox" } rule { source_labels = ["__param_target"] target_label = "instance" } rule { regex = "__meta_kubernetes_service_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_service_name"] target_label = "service" } } discovery.relabel "kubernetes_pods" { targets = discovery.kubernetes.kubernetes_pods.targets rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape_slow"] regex = "true" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})" target_label = "__address__" replacement = "[$2]:$1" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);((([0-9]+?)(\\.|$)){4})" target_label = "__address__" replacement = "$2:$1" } rule { regex = "__meta_kubernetes_pod_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_pod_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_pod_name"] target_label = "pod" } rule { source_labels = ["__meta_kubernetes_pod_phase"] regex = "Pending|Succeeded|Failed|Completed" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } discovery.relabel "kubernetes_pods_slow" { targets = discovery.kubernetes.kubernetes_pods_slow.targets rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scrape_slow"] regex = "true" action = "keep" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_scheme"] regex = "(https?)" target_label = "__scheme__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_path"] regex = "(.+)" target_label = "__metrics_path__" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})" target_label = "__address__" replacement = "[$2]:$1" } rule { source_labels = ["__meta_kubernetes_pod_annotation_prometheus_io_port", "__meta_kubernetes_pod_ip"] regex = "(\\d+);((([0-9]+?)(\\.|$)){4})" target_label = "__address__" replacement = "$2:$1" } rule { regex = "__meta_kubernetes_pod_annotation_prometheus_io_param_(.+)" replacement = "__param_$1" action = "labelmap" } rule { regex = "__meta_kubernetes_pod_label_(.+)" action = "labelmap" } rule { source_labels = ["__meta_kubernetes_namespace"] target_label = "namespace" } rule { source_labels = ["__meta_kubernetes_pod_name"] target_label = "pod" } rule { source_labels = ["__meta_kubernetes_pod_phase"] regex = "Pending|Succeeded|Failed|Completed" action = "drop" } rule { source_labels = ["__meta_kubernetes_pod_node_name"] target_label = "node" } } prometheus.scrape "prometheus" { targets = [{ __address__ = "localhost:9090", }] forward_to = [prometheus.remote_write.default.receiver] job_name = "prometheus" clustering { enabled = true } } prometheus.scrape "kubernetes_nodes" { targets = discovery.relabel.kubernetes_nodes.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-nodes" scheme = "https" authorization { type = "Bearer" credentials_file = "/var/run/secrets/kubernetes.io/serviceaccount/token" } tls_config { ca_file = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" insecure_skip_verify = true } clustering { enabled = true } } prometheus.scrape "kubernetes_nodes_cadvisor" { targets = discovery.relabel.kubernetes_nodes_cadvisor.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-nodes-cadvisor" scheme = "https" authorization { type = "Bearer" credentials_file = "/var/run/secrets/kubernetes.io/serviceaccount/token" } tls_config { ca_file = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" insecure_skip_verify = true } clustering { enabled = true } } prometheus.scrape "kubernetes_service_endpoints" { targets = discovery.relabel.kubernetes_service_endpoints.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-service-endpoints" honor_labels = true clustering { enabled = true } } prometheus.scrape "kubernetes_service_endpoints_slow" { targets = discovery.relabel.kubernetes_service_endpoints_slow.output forward_to = [prometheus.remote_write.default.receiver] job_name = "kubernetes-service-endpoints-slow" honor_labels = true scrape_interval =
2025-04-22