Wednesday, December 21, 2022

Kubernetes Grafana Dashboards

 I was trying to install Prometheus and Grafana in one of my Kube clusters. So I download Prometheus and Grafana helm repos, to my surprise most of the predefined dashboards that I found were not working, so I spent hours figuring out why; there were some missing metrics and components not installed by default. At the end, I was able to make some of those work.


For days, I thought that there was not a prebuilt Grafana/Prometheus dashboard solution until I took a look into Rancher, in their documentation they make a reference to Kube-Prometheus-Stack.  Not sure why I did not find this helm chart before, it already contains a full set of Grafana dashboards that will help you monitoring Kubernetes (pods, workloads, namespaces, etc). 


Here is the link to the Helm Chart.

Tuesday, February 9, 2021

User defined Java Class getRow null

 I have been working with Pentaho Kettle, and I needed to add some scripts, I decided to use Java since you can import some extra libraries, which is not allowed on Javascript component (or I haven't found how). 


I read the documentation and I implemented the processRows method, while testing I realized that getRow method was returning 'null' every time, at the beginning I thought it was related to the input type so I tried a couple, json, csv, excel, etc, and I always had the same result.


What was the solution? I was missing `putRow(...)` line, I am not sure what internally does but after adding it then getRow() started sending objects instead of null. I mean it makes kind of sense since if you miss putRow then whatever you do inside this component will not propagate further, I just wish it was documented somewhere.


So your code should look like this:



public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException

{

// you need this

Object[] r = getRow();

// this

r = createOutputRow(r, data.outputRowMeta.size());

// and this to send the row on to the next step.

putRow(data.outputRowMeta, r);



return true;

}



Wednesday, December 4, 2019

jenkins-log.txt Permission denied

I started getting the error below, after recreating Jenkins setup thru helm charts. At the beginning I thought I had missed to install a plugin, or installed one that corrupted Jenkins pipelines. So after starting from scratch I could not find why it was working before and then got broken.

sh: 1: cannot create /home/jenkins/agent/workspace/myproject/durable-48fa5881/jenkins-log.txt: Permission denied

So after reading a thread on Jenkins blog; I realized that "Jenkins" user is being used by Jenkins, and I was using "myuser" in my pod. So, I changed everything in my Dockerfile to match Jenkins slave image, like the following:

RUN groupadd --gid 10000 jenkins && useradd --gid 10000 --uid 10000 jenkins --shell /bin/bash
RUN mkdir /home/jenkins && chown -R jenkins:jenkins /home/jenkins
USER jenkins
WORKDIR /home/jenkins

After that, the permission denied error went away. I am still wondering how this was working before...


Tuesday, June 25, 2019

sbt-native-packager /opt/docker permission denied

I was getting all sorts of issues when trying to create files or directories below "/opt/docker" path. I tried adding:

import com.typesafe.sbt.packager.docker.DockerChmodType
dockerChmodType := DockerChmodType.UserGroupWriteExecute

It did not work, I was still getting errors, permission denied, while trying to write PID file to "/opt/docker/PID_FILE".

The solution is adding the following:

javaOptions in Universal ++= Seq(
  // Since play uses separate pidfile we have to provide it with a proper path  // name of the pid file must be play.pid  s"-Dpidfile.path=/var/run/play.pid")

Basically indicating Play framework to write PID file in another location, then:

dockerCommands ++= Seq(
  ExecCmd("RUN", "mkdir", "-p", s"/var/run/")
)

It would create another directory. Then, execute:

sbt dist && sbt docker:publishLocal

Finally you can write the following in a bash file:

dir=$(pwd)
docker run -v $dir/my_play_project:/var/run -v \ 
$dir/my_play_project/logs:/opt/docker/logs -p 9000:9000 \ 
 my_play_project:1.0


Sunday, December 27, 2015

NullPointer Exception while testing with Scala Futures...

So I was trying to unit testing Scala Futures, and I was getting NullPointerException out of nowhere. I was frustrated since the stacktrace didn't much more information, not a minimal clue of what was missing. It was until I payed attention to some other examples when I realized that I was missing something important:
import ExecutionContext.Implicits.global
I do not know why it wasn't detected at compile time, or why the exception was only coming as NullPointerException without any other hint. My test is something like this:

"Some test" should {
    "execute this" in {   
      val client = mock[AClass]
      val host = new BClass(client) 
      doReturn(Future {x}).when(client).aMethod(any[String], any[String]) // This was throwing a NPE
      val response = host.anyMethod(cI, mA, bL)
      Await.result(response, Duration(30, SECONDS)) 
      there was one(client). aMethod(any[String], any[String])
    }
  }


Thursday, October 8, 2015

starting with method newCanBuildFrom in object SortedSet

I was trying to loop over Scala Enumeration values like this:
  • aEnumeration.values.map(<something>)
And I got all sort of errors that seem to be unrelated to this. So I had to comment line by line to finally found this was causing the problem.

So, to remove this exception you just have to convert Enumeration values into a Scala List:
  • aEnumeration.values.toList.map(<something>)

Exception gone!

Tuesday, October 6, 2015

MAC getting rid of Nielsen NetSight malware

One of my friends got this thing on his Mac; Chrome and other browsers were crashing and eventually his computer restarted by itself.

I was disappointed on Mac response for help, basically they ask you to backup your data and reinstall OS (or upgrade to the next OS version).

Because we were in hurry, we did not want to do backup and reinstall, so we did the following:

  1. Look for a process named "Nielsen" in the Activity monitor, don't try to kill it, it will restart by itself. It seems, at least in my case, it goes under NetSight directories. 
  2. Double click over that process, and then click over "Open Files and Ports"
    • I found something like this " /Library/NetSight/KeyboardMouse.app"
  3. So you can do one of two things, either move it or delete it (if you are not admin then you have to prepend "sudo" without quotes to any of the following instructions):
    • Open a terminal and paste anyone of the following:
      • mv /Library/NetSight/KeyboardMouse.app ~/malware
      • rm -fr /Library/NetSight/KeyboardMouse.app 
  4. Finally remove anything related to that trash (once we did this the little icon on the top disappear after restarting):
    • sudo find / -name NetSight -exec rm -rf {} \;

 In our case we did not lose any data, and Mac is acting normal now; no more Chrome crashing or Mac restarting. Anyways do this under your own risk.