Stripping protocol and optional port from target

I’ve mostly managed to get scraping with Blackbox to work but I’m having issues normalizing the target FQDNs across my scrape configs. Here’s one of my scrape configs:

---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  name: &app exporter-blackbox
  namespace: monitoring
spec:
  scrapeInterval: 1m
  metricsPath: /probe
  params:
    module: [http_2xx]
  staticConfigs:
    - targets:
      - http://brother_hl-2270dw.internal.untouchedwagons.com
      - http://homeassistant.internal.untouchedwagons.com:8123
      - https://pve-cluster-node-01.internal.untouchedwagons.com:8006
  relabelings:
    - action: replace
      sourceLabels: [__address__]
      targetLabel: __param_target
    - action: replace
      sourceLabels: [__param_target]
      targetLabel: instance
    - action: replace
      targetLabel: __address__
      replacement: exporter-blackbox.monitoring.svc.cluster.local:9115
    - action: replace
      targetLabel: module
      replacement: http_2xx

There are other targets of course but as you can see two are http while the third is https, the first has no port specified while the second and third do. My other scrape jobs are similar with other modules and ports. What I want is the FQDN to be the same across all the jobs (IE pve-cluster-node-01.internal.untouchedwagons.com). I’ve tried using a regex to strip the protocol and optional port but I get alerts from Prometheus that these scrap jobs have been rejected.

  relabelings:
    - action: replace
      sourceLabels: [__address__]
      targetLabel: __param_target
    - action: replace
      sourceLabels: [__param_target]
      regex: ([\w\-.]+):?+[\d]* # This does not work
      replacement: '$1' # This does not work
      targetLabel: instance
    - action: replace
      targetLabel: __address__
      replacement: exporter-blackbox.monitoring.svc.cluster.local:9115
    - action: replace
      targetLabel: module
      replacement: ssh_banner

Well I got it working, I don’t know what the issue was, possibly the regular expression? Anyways this is what I’ve got:

apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  name: &app exporter-blackbox-tcp
  namespace: monitoring
spec:
  scrapeInterval: 1m
  metricsPath: /probe
  params:
    module: [tcp_connect]
  staticConfigs:
    - targets:
      - idrac-7p57cz1.internal.untouchedwagons.com:443
      - idrac-cjtyp22.internal.untouchedwagons.com:443
      - idrac-czblpd2.internal.untouchedwagons.com:443
      - idrac-jnky182.internal.untouchedwagons.com:443
      - ups.internal.untouchedwagons.com:3493
  relabelings:
    - action: replace
      sourceLabels: [__address__]
      targetLabel: __param_target
    - action: replace
      sourceLabels: [__param_target]
      regex: ([^:]+)(?::\d+)?   # The first group matches the host, the second matches the port.
      replacement: '$1'
      targetLabel: instance
    - action: replace
      targetLabel: __address__
      replacement: exporter-blackbox.monitoring.svc.cluster.local:9115
    - action: replace
      targetLabel: module
      replacement: tcp_connect

On the targets page the port will still be shown but it will be stripped as expected in the actual records.