Commit 165a763b authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

made http/https ports configurable in meepctl + added root url to metrics engine

parent 07bba441
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ ingress:
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
    # nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^(/api)$ $1/ redirect;
    # nginx.ingress.kubernetes.io/configuration-snippet: |
    #   rewrite ^(/api)$ $1/ redirect;

  labels: {}
  tls:
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ spec:
          ports:
            - containerPort: {{ .Values.deployment.port }}
              protocol: {{ .Values.deployment.protocol }}
          env:
            - name: MEEP_METRICS_ROOT_URL
              value: {{ .Values.image.env.rooturl }}
          {{- if .Values.codecov.enabled}}
          volumeMounts:
          - name: codecov-storage
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ image:
  repository: meep-metrics-engine
  tag: latest
  pullPolicy: Always
  env:
    rooturl: "http://www.example.com"

service:
  type: ClusterIP
+16 −5
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@ import (
	"errors"
	"fmt"
	"net/http"
	"net/url"
	"os"
	"strconv"
	"strings"
	"time"

	ceModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-ctrl-engine-model"
@@ -42,7 +45,7 @@ const metricNetwork = "network"
const moduleName string = "meep-metrics-engine"
const redisAddr string = "meep-redis-master:6379"

const basepathURL = "http://meep-metrics-engine/v2/"
const basePath = "/metrics/v2/"
const typeNetworkSubscription = "netsubs"
const typeEventSubscription = "eventsubs"

@@ -59,6 +62,7 @@ var eventSubscriptionMap = map[string]*EventRegistration{}
var activeModel *mod.Model
var activeScenarioName string
var metricStore *ms.MetricStore
var rootUrl *url.URL

var rc *redis.Connector

@@ -76,6 +80,13 @@ type NetworkRegistration struct {

// Init - Metrics engine initialization
func Init() (err error) {
	// Retrieve Root URL from environment variable
	rootUrl, err = url.Parse(strings.TrimSpace(os.Getenv("MEEP_METRICS_ROOT_URL")))
	if err != nil {
		rootUrl = new(url.URL)
	}
	log.Info("MEEP_METRICS_ROOT_URL: ", rootUrl)

	// Connect to Metric Store
	metricStore, err = ms.NewMetricStore("", influxDBAddr, redisAddr)
	if err != nil {
@@ -378,7 +389,7 @@ func createEventSubscription(w http.ResponseWriter, r *http.Request) {
		return
	}

	response.ResourceURL = basepathURL + "subscriptions/event/" + subsIdStr
	response.ResourceURL = rootUrl.String() + basePath + "subscriptions/event/" + subsIdStr
	response.SubscriptionId = subsIdStr
	response.SubscriptionType = eventSubscriptionParams.SubscriptionType
	response.Period = eventSubscriptionParams.Period
@@ -423,7 +434,7 @@ func createNetworkSubscription(w http.ResponseWriter, r *http.Request) {
		return
	}

	response.ResourceURL = basepathURL + "metrics/subscriptions/network/" + subsIdStr
	response.ResourceURL = rootUrl.String() + basePath + "metrics/subscriptions/network/" + subsIdStr
	response.SubscriptionId = subsIdStr
	response.SubscriptionType = networkSubscriptionParams.SubscriptionType
	response.Period = networkSubscriptionParams.Period
@@ -758,7 +769,7 @@ func getEventSubscription(w http.ResponseWriter, r *http.Request) {

	_ = rc.JSONGetList("", "", moduleName+":"+typeEventSubscription, populateEventList, &response)

	response.ResourceURL = basepathURL + "metrics/subscriptions/event"
	response.ResourceURL = rootUrl.String() + basePath + "metrics/subscriptions/event"
	jsonResponse, err := json.Marshal(response)
	if err != nil {
		log.Error(err.Error())
@@ -775,7 +786,7 @@ func getNetworkSubscription(w http.ResponseWriter, r *http.Request) {

	_ = rc.JSONGetList("", "", moduleName+":"+typeNetworkSubscription, populateNetworkList, &response)

	response.ResourceURL = basepathURL + "metrics/subscriptions/network"
	response.ResourceURL = rootUrl.String() + basePath + "metrics/subscriptions/network"
	jsonResponse, err := json.Marshal(response)
	if err != nil {
		log.Error(err.Error())
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import (
// configSet represents the set command
var configIp = &cobra.Command{
	Use:     "ip [IP]",
	Short:   "get/get node IP address in the meepctl config file",
	Short:   "get/set node IP address in the meepctl config file",
	Long:    "Get/Set node IP address in the meepctl config file",
	Example: "meepctl config ip 1.2.3.4",
	Args:    cobra.RangeArgs(0, 1),
Loading