cf_exporter icon indicating copy to clipboard operation
cf_exporter copied to clipboard

Draft: Adds possibility to call BBS to retrieve stats for application's processes states.

Open gmllt opened this issue 1 year ago • 5 comments

The purpose of this PR is to propose the use of BBS to fetch the RUNNING state of the main application process. This should help to avoid calls to /v2/space/:space_guid/summary endpoints

bbs internal client is configurable with :

      --bbs.api_url=BBS.API_URL  BBS API URL ($CF_EXPORTER_BBS_API_URL)
      --bbs.ca_file=BBS.CA_FILE  BBS CA File ($CF_EXPORTER_BBS_CA_FILE)
      --bbs.cert_file=BBS.CERT_FILE
                                 BBS Cert File ($CF_EXPORTER_BBS_CERT_FILE)
      --bbs.key_file=BBS.KEY_FILE
                                 BBS Key File ($CF_EXPORTER_BBS_KEY_FILE)
      --bbs.skip_ssl_verify      Disable SSL Verify for BBS ($CF_EXPORTER_BBS_SKIP_SSL_VERIFY)
      --bbs.timeout=5            BBS API Timeout ($CF_EXPORTER_BBS_TIMEOUT)

If bbs is not configured or unreachable, the code switch to the old method using /v2/space/:space_guid/summary to retrieve application running instances number.

Buildpacks information are retrieve with the new relationship introduced since CAPI 1.189.0

gmllt avatar May 30 '24 07:05 gmllt

Waiting for cloudfoundry/cloud_controller_ng!3863 to be merged and released. This will only work with capi shipping the correct version of cloud_controller_ng

gmllt avatar Jun 28 '24 12:06 gmllt

Waiting for cloudfoundry/cli!2933 to be merged.

gmllt avatar Aug 09 '24 09:08 gmllt

@gmllt the BBS API URL, what would that be ? => https://github.com/cloudfoundry/cf-deployment/blob/a0f8634a507108481c6b08304719ab7babace102/cf-deployment.yml#L151

benjaminguttmann-avtq avatar Feb 17 '25 11:02 benjaminguttmann-avtq

I receive always

ERRO[0100] unable to initialize bbs client error="failed to ping BBS" so would be good if you have an example config, so I can find out what I am doing wrong here

benjaminguttmann-avtq avatar Feb 17 '25 13:02 benjaminguttmann-avtq

got it to work, setting skip-ssl to true made the trick. Unfortunately the logs do not give you any insights why the connection did not work.

I don't think we do a fallback to the old logic, as it gets removed nevertheless. I would remove the fallback and make the BBS config optional, e.g. if the BBS config is not present do not gather the summary metrics as maybe not everyone wants to make BBS available to their monitoring VMs.

benjaminguttmann-avtq avatar Feb 19 '25 14:02 benjaminguttmann-avtq

@gmllt could you look into my latest comments and see if you can adjust accordingly?

benjaminguttmann-avtq avatar Apr 24 '25 09:04 benjaminguttmann-avtq

got it to work, setting skip-ssl to true made the trick. Unfortunately the logs do not give you any insights why the connection did not work.

Unfortunately, I haven't found any methods in the bbs client that allow me to retrieve anything other than a boolean on the connection test. I'll see if it's possible to suggest a modification.

I don't think we do a fallback to the old logic, as it gets removed nevertheless. I would remove the fallback and make the BBS config optional, e.g. if the BBS config is not present do not gather the summary metrics as maybe not everyone wants to make BBS available to their monitoring VMs.

I removed the fallback.

gmllt avatar May 01 '25 09:05 gmllt

@benjaminguttmann-avtq Currently, it's impossible to go beyond v8.11.0 of the Cloudfoundry CLI; cf_exporter depends on cf-go-client, which no longer works after a breaking change in v8.12.0. I'll look into this.

gmllt avatar May 01 '25 09:05 gmllt

Currently, it's impossible to go beyond v8.11.0 of the Cloudfoundry CLI; cf_exporter depends on cf-go-client, which no longer works after a breaking change in v8.12.0. I'll look into this.

cf-go-client-helper is now compatible with cloudfoundry/cli 8.13.0

gmllt avatar May 03 '25 08:05 gmllt

got it to work, setting skip-ssl to true made the trick. Unfortunately the logs do not give you any insights why the connection did not work.

Unfortunately, I haven't found any methods in the bbs client that allow me to retrieve anything other than a boolean on the connection test. I'll see if it's possible to suggest a modification.

Now using ActualLRPs request instead of Ping request. This brings more information is case of error.

gmllt avatar May 03 '25 09:05 gmllt

@benjaminguttmann-avtq as this is a breaking change, do you think it's interesting to start a github.com/cloudfoundry/cf_exporter/v2 ?

gmllt avatar May 03 '25 09:05 gmllt

@benjaminguttmann-avtq as this is a breaking change, do you think it's interesting to start a github.com/cloudfoundry/cf_exporter/v2 ?

Yes, I think it makes sense if we go with a v2 to mark the start of the only v3-api version

benjaminguttmann-avtq avatar May 03 '25 14:05 benjaminguttmann-avtq

@benjaminguttmann-avtq as this is a breaking change, do you think it's interesting to start a github.com/cloudfoundry/cf_exporter/v2 ?

Yes, I think it makes sense if we go with a v2 to mark the start of the only v3-api version

Done.

You can consider to merge this PR (or create a new v2 branch) if everything looks good for you :

  • Up to date with latest cloudfoundry/cli v8.13.0.
  • Using BBS in place of /v2/spaces/:space_guid/summary to retrieve running instances.
  • Using ActualLRPs BBS requests to test if BBS configuration works.
  • No Fallback to /v2/spaces/:space_guid/summary.

gmllt avatar May 04 '25 18:05 gmllt

@gmllt you think we should mentioned in the README that configuring the BBS values is optional?

benjaminguttmann-avtq avatar May 08 '25 11:05 benjaminguttmann-avtq

@gmllt is it expected that without configuring BBS I still get cf_application_instances and cf_application_running_instance ?

benjaminguttmann-avtq avatar May 21 '25 09:05 benjaminguttmann-avtq