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

Support influxdbv2 in custom metric drain #323

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ rvm:
- "2.4"
- "2.5"
- "2.6"
- "2.7"
Copy link
Member

Choose a reason for hiding this comment

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

The Toolbelt still uses 2.3, so we can't stop testing it.

$ /opt/aptible-toolbelt/embedded/bin/ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin19]

Copy link
Member Author

Choose a reason for hiding this comment

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

sadface, I'll see what I can do to get BigNumber behaving

Copy link
Member Author

Choose a reason for hiding this comment

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

finally figured it out - it was Bundler that was the biggest pain


before_install:
- ./cleanup_bundler
- gem install bundler -v '< 2'
script:
- bundle exec rake
- bundle exec script/sync-readme-usage
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Commands:
aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
aptible metric_drain:create:influxdb:customv2 HANDLE --org ORGANIZATION --token INFLUX_TOKEN --url URL_INCLUDING_PORT --bucket INFLUX_BUCKET_NAME --environment ENVIRONMENT # Create an InfluxDB v2 Metric Drain
aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
aptible metric_drain:list # List all Metric Drains
aptible operation:cancel OPERATION_ID # Cancel a running operation
Expand Down
1 change: 1 addition & 0 deletions aptible-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'chronic_duration', '~> 0.10.6'
spec.add_dependency 'cbor'
spec.add_dependency 'aws-sdk', '~> 2.0'
spec.add_dependency 'bigdecimal', '~> 1.3.5' # https://github.com/ruby/bigdecimal#which-version-should-you-select

# Temporarily pin ffi until https://github.com/ffi/ffi/issues/868 is fixed
spec.add_dependency 'ffi', '<= 1.14.1' if Gem.win_platform?
Expand Down
14 changes: 14 additions & 0 deletions cleanup_bundler
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

# Newer rubies have Bundler 2.x installed as default so it can't be deleted
# We need Bundler 1.x

gempaths = `gem env gempath`.split(':')
gempaths.each do |gempath|
# lookup bundler-*.gemspec files and delete them
# this is the only way to completely cleanup default bundler
# Note: the bundler gemspecs' paths are different for CRuby and JRuby
Dir.glob(gempath.strip + '/specifications/**/bundler-*.gemspec').each do |p|
File.delete(p)
end
end
29 changes: 29 additions & 0 deletions lib/aptible/cli/subcommands/metric_drain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ def self.included(thor)
create_metric_drain(account, opts)
end

desc 'metric_drain:create:influxdb:customv2 HANDLE '\
'--org ORGANIZATION --token INFLUX_TOKEN ' \
'--url URL_INCLUDING_PORT ' \
'--bucket INFLUX_BUCKET_NAME ' \
'--environment ENVIRONMENT',
'Create an InfluxDB v2 Metric Drain'
option :bucket, type: :string
option :org, type: :string
option :token, type: :string
option :url, type: :string
option :environment
define_method 'metric_drain:create:influxdb:customv2' do |handle|
account = ensure_environment(options)

config = {
address: options[:url],
org: options[:org],
authToken: options[:token],
bucket: options[:bucket]
}
opts = {
handle: handle,
drain_configuration: config,
drain_type: :influxdb2
}

create_metric_drain(account, opts)
end

desc 'metric_drain:create:datadog HANDLE '\
'--api_key DATADOG_API_KEY '\
'--site DATADOG_SITE ' \
Expand Down
28 changes: 27 additions & 1 deletion spec/aptible/cli/subcommands/metric_drain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def expect_provision_metric_drain(create_opts, provision_opts = {})
end

context 'influxdb:custom' do
it 'creates a new InfluxDB metric drain' do
it 'creates a new InfluxDB v1 metric drain' do
opts = {
handle: 'test-influxdb-custom',
drain_type: :influxdb,
Expand All @@ -111,6 +111,32 @@ def expect_provision_metric_drain(create_opts, provision_opts = {})
end
end

context 'influxdb:customv2' do
it 'creates a new InfluxDB v2 metric drain' do
opts = {
handle: 'test-influxdb2-custom',
drain_type: :influxdb2,
drain_configuration: {
address: 'https://test.foo.com:443',
org: 'foobar',
authToken: 'bar',
bucket: 'foo'
}
}
expect_provision_metric_drain(opts)

subject.options = {
environment: account.handle,
bucket: 'foo',
token: 'bar',
org: 'foobar',
url: 'https://test.foo.com:443'
}
subject.send('metric_drain:create:influxdb:customv2',
'test-influxdb2-custom')
end
end

context 'datadog' do
it 'creates a new Datadog metric drain' do
opts = {
Expand Down