InfluxDBv2 - get a remote config working as a telegraf windows service - windows

I'm trying to use the remote config feature of InfluxDB and Telegraf. If I set the enviroment variable with
$env:INFLUX_TOKEN = "thisIsMyToken"
and then test things with
.\telegraf.exe --config "https://influxdbserver:port/myremoteconfig" --test
it seems to be working.
When I try to install the service with
.\telegraf.exe --service install --config "https://influxdbserver:port/myremoteconfig"
the connection does not work and according to the windows event manager it can't load the config file due to "401 Unauthorized". Which is the same error I get when not setting the token before using the --test command.
I assume the problem is with the service not seeing the enviroment variable. But how can I get the variable into the service?

You can use setx, though that'll set an env var that all users on your system can view
setx /M INFLUX_TOKEN "ThisisMyToken"
credits to kittenless_tootler

Related

Error when attempting to access azure aks with kubectl

W0111 13:21:23.866650 172 azure.go:92] WARNING: the azure auth plugin is deprecated in v1.22+, unavailable in v1.26+; use https://github.com/Azure/kubelogin instead.
To learn more, consult https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins
This is the error I get in cmd, powershell, git-bash, azure shell & vscode terminal. Also I get the same issue if I go to the azure portal and use the web shell.
Yes if I use the terminal in Mirantis lens kubectl works as expected the only difference being is that I've added a http proxy in the Proxy settings for Lens.
I belive the issue is caused by the terminal not using the http proxy.
I've added a system environment variable through advanced system settings, which doesn't appear to be used in my terminal session.
How can I use the http proxy during sessions to use kubectl to access AKS and how can I check if the terminal is using the http proxy?
Installed kubelogin as above
Checked that the proxy was running using Get-Proxess px*
Checked that the environment variable was set with the correct value by doing ls $env: and listing all envvars
You are correct, the problem is with the client.
It seems you are using a client version > 1.26, which as the error suggests its removed.
The easiest thing you can do is to use an older version of the kubectl client.

Switching AWS profile via the AWS CLI in VS Code integrated terminal does not work

My different AWS profiles from various projects are stored in the standard config-file C:\Users\username\.aws\config.
According to the official documentation it should be as easy as executing the following commands in my integrated CMD-prompt terminal in VS Code.
setx AWS_PROFILE default
Using setx to set an environment variable changes the value in all
command shells that you create after running the command.
Next, open a new cmd-terminal session like so:
Checking the caller identity does not show what I expect to see:
aws sts get-caller-identity
An error occurred (ExpiredToken) when calling the AssumeRole
operation: The security token included in the request is expired.
Carrying out the reload window - command did also not resolve the issue:
Next thing I tried was the mere set- instead of the previous setx - command:
Using set to set an environment variable changes the value used until
the end of the current command prompt session, or until you set the
variable to a different value.
Carrying out this leads to the following output:
set AWS_PROFILE default
AWS_PROFILE=profile_name_from_other_project
Even if I delete all open (integrated) CMD-shell after using setx and opening a new one, the profile from the other project is still active:
Finally, I switched to my already open integrated bash - shell in VS Code and executed the command:
export AWS_PROFILE=default
This magically worked:
❯ aws sts get-caller-identity
{
"UserId": "A....",
"Account": "7.....",
"Arn": "arn:aws:iam::7....:user/username"
}
I'm still wondering why I cannot make it work in the integrated VS-Code CMD-terminal..

NSSM: Can't edit a service I created

I am using NSSM to create a service, however, after creation I need to set some parameters, such as AppDirectory, AppNoConsole, etc.
I am able to create the service using the GUI, but I want to do it via cmd, for which I have a batch file that goes like this:
nssm install MyService "%Java_Exe_Path%" "-Xmx1024M -classpath \bin\start.jar;\lib\*;. com.myapp.class.subclass start"
nssm set MyService AppDirectory "%DIR%"
nssm set MyService AppNoConsole 1
Thing is I am getting errors that read:
Can't open service! OpenService(): Access is denied.
Or
OpenService(): The specified service does not exist as an installed service.
Notes: When I run the cmd file I get asked for admin rights (guessing to run the install), but to edit (set) I am not being requested permissions, neither I get asked permissions if I run the set command directly via commandline (also getting an error of access denied).
Can anyone help?
Thanks!
Got the same problem, my solution is always run this script as an administrator:
How to request Administrator access inside a batch file

Why Jenkins isn't able to start the service, but it is starting fine when I start it manually?

I am trying to start HYBRIS server from Jenkins.
When I run the sh hybrisserver.sh start command manually in the server it starts correctly.
But, when I try to run the same command through Jenkins it is not able to start the service.
The Hybris server and Jenkins master are connected through a slave (node).
What could be the issue?
You can include following line of entry on jenkins job and it will start nicely.
export CATALINA_BASE="<Your Hybris DIR>/hybris/bin/platform/tomcat"
export WRAPPER_CONF="$CATALINA_BASE/conf/wrapper.conf"
sudo sh <Your Hybris DIR>/hybris/bin/platform/tomcat/bin/wrapper.sh start
try setting up tools environment
using https://wiki.jenkins-ci.org/display/JENKINS/Tool+Environment+Plugin
then set up required env variable and run slave as cmd through admin rights

Running mongod as a windows service

i have installed mongodb on win32 and i am trying to run it as a service.
I have followed the instructions posted here: http://www.deltasdevelopers.com/post/Running-MongoDB-as-a-Windows-Service.aspx
but when when windows tries to 'load'/'run' the service there is a problem. I see the service under the services control banner constantly in the 'starting' state.
The result: the service is not started and windows is constantly trying to start it without success.
The instructions i have followed are:
At the command line
C:\mongodb\mongod -install
then
C:\mongodb\mongod -service
Then i modified the Win Registry Entry for the MongoDB Service by setting the ImagePath key to the value of C:\mongodb\mongodb.exe -service
Any advice? What am i doing wrong?
Just for future reference: running mongo as a windows service
Also lots of people seem to be saying: specify the whole path to the mongod.exe:
c:\mongo\mongod.exe --logpath "c:\mongo\logs\mongo.log" --logappend --dbpath "c:\mongo\data" --directoryperdb --install
Also if you're running Windows 7 don't forget to run the command window as an administrator.
I'd do it this way just cause I like to customize/organize things better:
Unzip mongo to where you want.
I like putting all the configuration in a file (my preference, since I didnt like default location of C:/data/db, and didn't like all the options as commandline params)...
Looks something like:
[C:\dev\mongodb\data\mongodb.conf]
dbpath = C:\dev\mongodb\data\db
logpath = C:\dev\mongodb\data\mongodb.log.txt
logappend = false
Then I put C:\dev\mongodb\bin in my Env Variable's PATH (so can call mongo.exe from any dir), but not needed...
Then on command line to install the Windows Service:
$ cd C:\dev\mongodb\bin
$ mongod.exe -f C:\dev\mongodb\data\mongodb.conf --install
It will create a Windows Service which if you want, can start manually via:
$ net start MongoDB
//Use qoutes if changed service name (via -serviceName to mongod --install), like: net start "Mongo DB"
Specifying several parameters at once is a good choice.
mongod
--install
to install as a service
--rest
to enable rest access to mongodb
–master
to set up mongodb instance as master.
–logpath
this is mandatory when you install mongodb as service
--dbpath
this too is mandatory for mongodb to run.
Here is a step by step guide describing the installation of MongoDB Service on Windows 7.
I have been faced similar issue. And i tried above solutions still have not get any result.
finally below code is solved my issue.
-> Command prompt open as administrator.
-> Copy and paste the below code after changing the proper bin and config path.
sc.exe create MongoDB binPath= "\"d:\MongoDB\bin\mongod.exe\" --service --config=\"d:\MongoDB\mongo.cfg\"" DisplayName= "MongoDB" start= "auto"
Happy Coding !!!!!!
Regardless of whether you're running as a service or not, you need to specify the --dbpath argument to mongod.exe.
Also, you shouldn't have to edit the registry. You can just issue the command like this:
C:\mongodb\mongod.exe --dbpath C:\data\db --install

Resources