Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CustomMetrics): Allow Different App to Send Custom Metrics #3211

Merged
merged 14 commits into from
Oct 28, 2024

Conversation

asalan316
Copy link
Contributor

@asalan316 asalan316 commented Sep 17, 2024

Previously, only the application sending custom metrics to the autoscaler could be scaled.

The new feature enables users to scale an application based on custom metrics sent by another app (Custom Metrics Producer), This is achieve if:

  • Both applications are bound to same application autoscaler instance
  • The application to scale has the "metric_submission_strategy.allow_from" set to bound_app during the binding process

How It Works

To enable this feature, specify the metric_submission_strategy.allow_from : "bound_app" parameter in the configuration object during the binding process with the application to be scaled (as shown below)

Binding Configuration (aka.scaling policy)

{
  "configuration": {
    "custom_metrics": {
      "metric_submission_strategy": {
        "allow_from": "bound_app"
      }
    }
  },
  "instance_max_count":4,
  "instance_min_count":1,
  "scaling_rules":[
    {
      "metric_type":"test_metric",
      "threshold":500,
      "operator":">",
      "adjustment":"+1"
    }, {
      "metric_type":"test_metric",
      "threshold":100,
      "operator":"<",
      "adjustment":"-1"
    }
  ]
}

Bind to Applications

# Bind autoscaler to application to scale

cf bind-service  app-to-scale  autosocaler -c <binding Configuration.json>

# Bind autoscaler to custom metrics producer app

cf bind-service  custom-metrics-producer-app  autosocaler

custom-metrics-strategy-v1-drawio

Other Changes

  • Introduced additional database bindingDB in metricsforwarder service to retrieve binding information
  • Added New Database schema to validate custom metrics strategy - allowed values are bound_app and same_app (default)
  • Introduced a configuration structure to differentiate between policy and binding configurations
  • Binding parameters are retrieved as follows:
    • For existing bindings (without configuration) - only policy json is displayed (existing behavior)
    • For new bindings - both the configuration and policy json are displayed in the response

@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch from fae6122 to 9859b16 Compare September 17, 2024 10:08
@asalan316 asalan316 added the allow-acceptance-tests This label needs to be added to enable the acceptance tests to run. label Sep 17, 2024
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch 3 times, most recently from 3edfa26 to c217dd7 Compare September 20, 2024 12:59
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch from a4de8af to f63ba3c Compare September 27, 2024 14:18
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch 8 times, most recently from b30a9fc to 200be0b Compare October 2, 2024 14:32
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch 7 times, most recently from 31ee44d to 2e9256a Compare October 17, 2024 13:03
@asalan316 asalan316 changed the title Neighbour app custom metrics Allow Different App to Send Custom Metrics Oct 17, 2024
@asalan316 asalan316 changed the title Allow Different App to Send Custom Metrics feat(CustomMetrics): Allow Different App to Send Custom Metrics Oct 17, 2024
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch 5 times, most recently from 1fb8dce to 840fa60 Compare October 18, 2024 12:46
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch 3 times, most recently from b105a31 to 3b57893 Compare October 22, 2024 11:40
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch from 3b57893 to 1cd4ac9 Compare October 22, 2024 12:49
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch from b67cb3c to 979581a Compare October 22, 2024 14:08
@asalan316 asalan316 force-pushed the neighbour-app-cutom-metrics branch from 8d27a10 to dec3f28 Compare October 22, 2024 17:02
@bonzofenix bonzofenix force-pushed the neighbour-app-cutom-metrics branch from 0eee25c to dec3f28 Compare October 23, 2024 15:38
bonzofenix and others added 2 commits October 24, 2024 15:27
 • Abstracted database configuration logic into configureDb function for reuse
 • Extended configuration to support BindingDb alongside PolicyDb
 • Updated tests to reflect additional BindingDb configuration
 • Added binding_db tag to mta.tpl.yaml resources
@bonzofenix bonzofenix removed the allow-acceptance-tests This label needs to be added to enable the acceptance tests to run. label Oct 24, 2024
@bonzofenix bonzofenix added the allow-acceptance-tests This label needs to be added to enable the acceptance tests to run. label Oct 25, 2024
jobs/metricsforwarder/spec Show resolved Hide resolved
src/acceptance/app/custom_metric_test.go Outdated Show resolved Hide resolved
src/acceptance/app/custom_metric_test.go Outdated Show resolved Hide resolved
src/acceptance/broker/broker_test.go Outdated Show resolved Hide resolved
src/acceptance/broker/broker_test.go Show resolved Hide resolved
src/autoscaler/metricsforwarder/server/auth/auth_test.go Outdated Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
5.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Contributor

@bonzofenix bonzofenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@asalan316 asalan316 merged commit e1af052 into main Oct 28, 2024
37 of 38 checks passed
@asalan316 asalan316 deleted the neighbour-app-cutom-metrics branch October 28, 2024 15:40
@asalan316
Copy link
Contributor Author

The description says: "For new bindings - both the configuration and policy json are displayed in the response". This has changed the behaviour of the existing functionality. fixed and released in 14.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
allow-acceptance-tests This label needs to be added to enable the acceptance tests to run. enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants