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

Mask subdomain of chef server api_fqdn before sending to telemetry #3883

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@
# Select whether data_collector affects overall status in _status endpoint
default['private_chef']['data_collector']['health_check'] = true

default['private_chef']['ctl_command'] = "#{ChefUtils::Dist::Server::SERVER_CTL}"
default['private_chef']['running_filepath'] = "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}-running.json"
##
# Compliance Profiles
##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@
},

{metrics_module, folsom_metrics}
]}
]},

{chef_telemetry, [
{running_filepath, "<%= node['private_chef']['running_filepath'] %>"},
{ctl_command, "<%= node['private_chef']['ctl_command'] %>"}
]
}

<% if !node['private_chef']['opscode-erchef']['ssl_session_caching']['enabled'] -%>
,
Expand Down
15 changes: 15 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.eunit
deps/
ebin/
ebin_dialyzer/
TAGS
.DS_Store
doc/*.html
*.beam
/doc/edoc-info
/doc/erlang.png
/doc/stylesheet.css
/deps.plt
test/*.out
.rebar
log/
30 changes: 30 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
REBAR3_URL=https://s3.amazonaws.com/rebar3/rebar3

# If there is a rebar in the current directory, use it
ifeq ($(wildcard rebar3),rebar3)
REBAR3 = $(CURDIR)/rebar3
endif

# Fallback to rebar on PATH
REBAR3 ?= $(shell which rebar3)

# And finally, prep to download rebar if all else fails
ifeq ($(REBAR3),)
REBAR3 = rebar3
endif

all: $(REBAR3)
@$(REBAR3) do clean, compile, eunit, dialyzer

rel: all
@$(REBAR3) release

distclean:
@rm -rf _build

$(REBAR3):
curl -Lo rebar3 $(REBAR3_URL) || wget $(REBAR3_URL)
chmod a+x rebar3

install: $(REBAR3) distclean
$(REBAR3) update
3 changes: 3 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Telemetry

Telemetry is an HTTP exporter of Chef Server node stats for external services.
Empty file.
26 changes: 26 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%% -*- mode: erlang -*-
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et

{deps,
[
%% lager has to come first since we use its parse transform
{lager, ".*",
{git, "https://github.com/erlang-lager/lager", {branch, "master"}}}
]
}.

{profiles, [{
test, [
{deps, [meck]},
{erl_opts, [export_all]}
]
}]}.

{erl_opts, [
warnings_as_errors,
{parse_transform, lager_transform},
debug_info
]}.

{cover_enabled, true}.
34 changes: 34 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/src/chef_telemetry.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92 -*-
%% ex: ts=4 sw=4 et
%%
%%
%% Copyright 2016 Chef Software, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%

{application, chef_telemetry, [
{description, "Chef Server Telemetry"},
{vsn, {cmd,"cat ../../VERSION | awk '{print $0}'"}},
{registered, []},
{applications, [
kernel,
stdlib,
lager,
chef_secrets,
opscoderl_httpc
]},
{mod, {chef_telemetry_app, []}}
]}.
34 changes: 34 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/src/chef_telemetry.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92 -*-
%% ex: ts=4 sw=4 et
%%
%%
%% Copyright 2016 Chef Software, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%

-module(chef_telemetry).
-export([
is_enabled/0
]).

-spec is_enabled() -> boolean().
is_enabled() ->
case envy:get(chef_telemetry, is_enabled, true, boolean) of
true ->
true;
_ ->
false
end.
34 changes: 34 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/src/chef_telemetry_app.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92 -*-
%% ex: ts=4 sw=4 et
%%
%% Copyright 2016 Chef Software, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%

-module(chef_telemetry_app).

-behaviour(application).

%% API
-export([start/2,
stop/1
]).

start(_StartType, _StartArgs) ->
chef_telemetry_sup:start_link().

stop(_State) ->
ok.
37 changes: 37 additions & 0 deletions src/oc_erchef/apps/chef_telemetry/src/chef_telemetry_sup.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92 -*-
%% ex: ts=4 sw=4 et
%%
%%
%% Copyright 2016 Chef Software, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%

-module(chef_telemetry_sup).

-behaviour(supervisor).

-export([init/1,
start_link/0
]).

start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init([]) ->
Worker = {chef_telemetry_worker,
{chef_telemetry_worker, start_link, []},
permanent, 5000, supervisor, [chef_telemetry_worker]},
{ok, {{one_for_one, 10, 10}, [Worker]}}.
Loading
Loading