hertzbeat icon indicating copy to clipboard operation
hertzbeat copied to clipboard

[Question] Multi Tenant HTTP Template

Open ldubrois opened this issue 4 months ago • 10 comments

Question

Hi

I have just installed Hertzbeat. I want to monitor our Cloud solution. This is a B2B multi-tenant solution.

I would like to monitor a set of URL for each tenant :

https://ws.site.com/api/tenants/{tenantCode}/endpoint https://auth.site.com/app/tenants/{tenantCode}/probe https://app.site.com/myapp/tenants/{tenantCode}/entity/action

To do that, I tried to create a Template with a field

  - field: tenantCode
    name:
      en-US: Tenant's Code
    type: text
    required: true

And one text field for each hostname (it seems I can/must have one host field)

And in the metrics :


  - name: app-probe
    i18n:
      en-US: App Probe
    priority: 0
    interval: 600
    fields:
      - field: responseTime
        type: 0
        unit: ms
      - field: statusCode
        type: 0
    protocol: http
    http:
      host: ^_^ws_host^_^
      port: 443
      timeout: 30
      url: /api/tenants/^_^tenantCode^_^/endpoint 
      method: GET
      ssl: true      
      successCodes: [200,204]
      parseType: website

It does not seems to work ; will hertzbeat do replace in a the string of is it only field mapping ?

ldubrois avatar Sep 03 '25 08:09 ldubrois

Can I see all the actual requests made by Hertztbeat ? And the results ?

ldubrois avatar Sep 03 '25 08:09 ldubrois

change the priority in app-probe and make sure it is greater than that in tenantCode @ldubrois

Calvin979 avatar Sep 03 '25 13:09 Calvin979

Thanks.

I can't put priority on the field tenantCode

On the metrics it enforce at least one with Priority at 0.

Is there a documentation about this ?

Can i change the console output of Docker to see all the requests made ? And make sure they are all correctly replaced ?

ldubrois avatar Sep 04 '25 07:09 ldubrois

@ldubrois We don't have corresponding docs about this functionality. Can paste your yml here and I will let you know how to modify

Calvin979 avatar Sep 04 '25 07:09 Calvin979

Hello

What i am trying to achieve :

category: i2a
app: tenant_monitoring
name:
  en-US: Tenant's Monitoring
params:
  - field: host
    name:
      en-US: Default Host
    type: host
    defaultValue: my.site.com
    required: true

  - field: tenantCode
    name:
      en-US: Tenant's Code
    type: text
    required: true
  - field: datacenter
    name:
      en-US: Datacenter name
    type: text
    defaultValue: dc01
    required: true
  - field: public_host_ws
    name:
      en-US: Public Host WS
    type: text
    defaultValue: my-ws.site.com
    required: true
  - field: public_host_auth
    name:
      en-US: Public Host Auth
    type: text
    defaultValue: auth.site.com
    required: true
  - field: public_host_mds
    name:
      en-US: Public Host MDS
    type: text
    defaultValue: app.site.com
    required: true
  - field: private_host
    name:
      en-US: Private Host
    type: text
    defaultValue: my.site.local
    required: true

metrics:
  - name: login-options
    i18n:
      en-US: Login Options
    priority: 0
    interval: 60
    fields:
      - field: responseTime
        type: 0
        unit: ms
      - field: statusCode
        type: 0
    protocol: http
    http:
      host: dc01-auth.i-2a.com
      port: 443
      url: /tenants/^_^tenantCode^_^/account/LoginOptions?userName=
      method: GET
      ssl: true
      successCodes: [200,204]
      parseType: website

  - name: api-resources
    i18n:
      en-US: API Resources
    priority: 10
    interval: 30
    fields:
      - field: responseTime
        type: 0
        unit: ms
      - field: statusCode
        type: 0
    protocol: http
    http:
      host: dc01-ws.i-2a.com
      port: 443
      timeout: 30
      url: /apis/v1/tenants/^_^tenantCode^_^/localizations/resources?culture=en&requester=4&devMode=false
      method: GET
      ssl: true      
      successCodes: [200,204]
      parseType: website

   - name: api-back-users
     i18n:
       en-US: API Back Users
     priority: 10
     fields:
       - field: responseTime
         type: 0
         unit: ms
     protocol: http
     http:
       host: ^_^private_host^_^
       port: 443
       timeout: 30
       url: /apis/directory/v1/tenants/^_^tenantCode^_^/users/first?filter=true
       method: GET
       ssl: true      
       successCodes: [200,204]
       parseType: website

  - name: mds-smart-probe
    i18n:
      en-US: MDS Smart Probe
    priority: 10
    interval: 600
    fields:
      - field: responseTime
        type: 0
        unit: ms
      - field: statusCode
        type: 0
    protocol: http
    http:
      host: dc01.i-2a.com
      port: 443
      timeout: 30
      url: /apis/my-data-security/v1/tenants/^_^tenantCode^_^/probes/smart
      method: GET
      ssl: true      
      successCodes: [200,204]
      parseType: website

  - name: mds-resources
    i18n:
      en-US: MDS Resources
    priority: 10
    interval: 30
    fields:
      - field: responseTime
        type: 0
        unit: ms
      - field: statusCode
        type: 0
    protocol: http
    http:
      host: dc01.i-2a.com
      port: 443
      timeout: 30
      url: /apis/my-data-security/v1/tenants/^_^tenantCode^_^/localizations/resources?culture=en&requester=10
      method: GET
      ssl: true      
      successCodes: [200,204]
      parseType: website

ldubrois avatar Sep 04 '25 07:09 ldubrois

looks like these is no problem on the yml, could you paste the exception here as well?

Calvin979 avatar Sep 04 '25 08:09 Calvin979

Before changing the priority the status was constantly changing up/down

If I try to put a priority above 0 on all metrics :

Image

My concern is : will the first metric with priority 0 does work ?

ldubrois avatar Sep 04 '25 08:09 ldubrois

@ldubrois

Image

zqr10159 avatar Sep 04 '25 16:09 zqr10159

I think I made a mistake during the copy / paste because the YML is valid on my side

ldubrois avatar Sep 05 '25 08:09 ldubrois

thanks for your help

I think I will use the HTTP API to industrialize the tenant's monitor so I will also create labels, assign the labels to the monitors, etc

ldubrois avatar Sep 05 '25 12:09 ldubrois